question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

the search ignores the symbols

See original GitHub issue

Hello,

I added flexsearch library to my application. This works very well in the most cases. However, I have problems when I try to perform searches that combine words and symbols like &, !, #, %. For example:

We have a collection with 4 items:

  1. Course&Some
  2. Course#Another
  3. Course%Foo
  4. Course!Bar

When I try searching the term ‘Course&’ (ignore single quotes), the library returns 4 results, ignoring the symbol &. I expect one result (the item number one). When I try searching the term ‘Course&Another’ (ignore single quotes), the library returns 3 results (items two, three and four). I expect zero results.

So, my questions are:

  1. How should I proceed so that the library does not ignore the symbols when searching?
  2. Is there a way to improve the behavior of the library with cases like the ones mentioned?

I am using this configuration:

var index = new FlexSearch({
        encode: "advanced",
        tokenize: "full",
        depth: 3,
        threshold: 0,
        async: false,
        worker: false,
        cache: false,
        doc: {
            id: "Id",
            field: [
                "Field1",
                "Field2"
            ];
        }
    });
index.add(collectionItems);

I perform the search in the following way:

var params = { field: ["Field1", "Field2"], query: text, bool: "or" }

index.search(params, function (results) {
	//More code    
}

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jladburycommented, Nov 18, 2020

@carlinmack Thanks for taking an interest! I delved a little deeper and found that this works fine for my purposes:

tokenize: function(str){
	return str.split(/\s+/g);
}

I think it will also suit the riginal poster @javierperini.

1reaction
carlinmackcommented, Nov 6, 2020

I reckon the tokenize function full takes in your input and sanitises it, I would define a custom encoding function

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do search engines ignore symbols? - Stack Overflow
Why do search engines seem to ignore symbols completely? They are just characters like any others. I can see why it would be...
Read more >
Why does Google search STILL ignore symbols? - Quora
The insignificant words and symbols are ignored because they don't add anything to the quality of the results retrieved.
Read more >
Google Ignores Symbols For Rankings
John Mueller of Google said that Google, for ranking and SEO purposes, ignores all symbols - including the registered trademark symbols such ...
Read more >
8 Easy Symbols to Make Google Work Better for You
– (Negative Symbol): adding '-' before a word in a query will tell a search engine to ignore pages that use that word...
Read more >
Refine web searches - Google Search Help
You can use symbols or words in your search to make your search results more precise. Google Search usually ignores punctuation that isn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found