Skip to content

Multiple word searching with List.search - closes #680 #682

Closed
sheffieldnikki wants to merge 38 commits into
javve:masterfrom
sheffieldnikki:multi-word-search
Closed

Multiple word searching with List.search - closes #680 #682
sheffieldnikki wants to merge 38 commits into
javve:masterfrom
sheffieldnikki:multi-word-search

Conversation

@sheffieldnikki

Copy link
Copy Markdown
Contributor

Default search function now supports fast multi-word searching as well as exact matching of quoted phrases. See #680

Added documentation to List API and test units to __test__/search.test.js
(also fixes a few typos in __test__/search.test.js)

clbn and others added 30 commits November 17, 2017 16:02
Changed license date
Now LICENSE is up to date.
LICENSE and README.md files are not up to date
Fix typos in error message
@codecov-io

codecov-io commented Apr 2, 2020

Copy link
Copy Markdown

Codecov Report

Merging #682 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #682   +/-   ##
=======================================
  Coverage   94.78%   94.78%           
=======================================
  Files          19       19           
  Lines         806      806           
  Branches      190      190           
=======================================
  Hits          764      764           
  Misses         29       29           
  Partials       13       13           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec685e7...ec685e7. Read the comment docs.

@sheffieldnikki

sheffieldnikki commented Apr 5, 2020

Copy link
Copy Markdown
Contributor Author

If this multi-word search is accepted into the library, replacing the default search, is it worth having fuzzy search built-in as well? Fuzzy search is 10% of the List.min.js size, and it could easily be built as a separate file list-fuzzysearch.js (doesn't even need to be a plugin) that provides a custom search function for projects that need it?

@codecov-commenter

codecov-commenter commented May 19, 2020

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@dfc930e). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #682   +/-   ##
=========================================
  Coverage          ?   94.78%           
=========================================
  Files             ?       19           
  Lines             ?      806           
  Branches          ?      190           
=========================================
  Hits              ?      764           
  Misses            ?       29           
  Partials          ?       13           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dfc930e...ec685e7. Read the comment docs.

Comment thread src/search.js
Comment on lines 58 to +59
for (var k = 0, kl = list.items.length; k < kl; k++) {
search.item(list.items[k]);
}
},
item: function(item) {
item.found = false;
for (var j = 0, jl = columns.length; j < jl; j++) {
if (search.values(item.values(), columns[j])) {
item.found = true;
return;
}
}
},
values: function(values, column) {
if (values.hasOwnProperty(column)) {
text = list.utils.toString(values[column]).toLowerCase();
if ((searchString !== "") && (text.search(searchString) > -1)) {
return true;
var item = list.items[k];

@buczek buczek Sep 16, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (var item of list.items) { ?
(same with following loops)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The array iteration used in the code was tested as being the fastest across multiple browsers, and is also compatible with all browsers. for ... of ... isn't compatible with older browsers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then its certainly better the way it is 👍

Comment thread src/search.js
for (var i = 0, il = words.length; i < il; i++) {
var word_found = false;
for (var j = 0, jl = columns.length; j < jl; j++) {
var values = item.values(), column = columns[j];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lift var values = item.values()out of the two inner loops?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definite improvement :) Thanks

@javve

javve commented Nov 23, 2020

Copy link
Copy Markdown
Owner

Merged into #696

@javve javve closed this Nov 23, 2020
@eng1neer

Copy link
Copy Markdown

Great update! Looks like it unexpectedly (well, at least to me 🙂) changed the behavior of searches that contain URLs though: previously in version 1.5.0 I could search for "example.com" just fine, and now it seems to split it into two words and it stopped working. Any way to search for an exact match (quoted "example.com" does not work either)?

@sheffieldnikki

Copy link
Copy Markdown
Contributor Author

Great update! Looks like it unexpectedly (well, at least to me slightly_smiling_face) changed the behavior of searches that contain URLs though: previously in version 1.5.0 I could search for "example.com" just fine, and now it seems to split it into two words and it stopped working. Any way to search for an exact match (quoted "example.com" does not work either)?

Can you submit a new issue with this bug please? and example code showing it failing. This code should only split words on whitespace (space, tab, newline) characters, not on a period, so 'example.com' should work without needing exact-match quoting.

@eng1neer

Copy link
Copy Markdown

@sheffieldnick #715

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants