nextapps-de / flexsearch

Next-Generation full text search library for Browser and Node.js
Apache License 2.0
12.53k stars 491 forks source link

No match when search term has previous unmatched word? #190

Closed daviddean99 closed 3 years ago

daviddean99 commented 4 years ago

I have an index of job titles like this:

"College Recruiter"
"Contract Recruiter"
"Corporate Recruiter"
"Employment Recruiter"
"Executive Recruiter"
"Recruiter"

...and I'm using these settings to build the search index:

    tokenize: "icase",
    encode: "simple",
    cache: false,
    async: false,
    worker: false,
    threshold: 0,
    resolution: 9,
    depth: 1,

...and the search parameters are all default apart from limiting to 10 results:

filterResults = index.search(searchQuery, 10);

If someone searches for "Recruiter" then all matching job title are being returned, regardless of where in the title the word "Recruiter" is. That's perfect.

The problem is where someone searches for a job title that starts with another word, for example "Technical Recruiter" or "Internal Recruiter". In that case the leading word is not matched so FlexSearch does not return any matches.

In this case I would like FlexSearch to still return matches for the word "Recruiter" even if the previous word e.g. "Internal" does not have any matches.

I guess the problem is that FlexSearch is treating the entire two word entry as one search term, instead of searching first for an exact match "Internal AND Recruiter" then trying the words separately i.e. "Internal OR Recruiter".

Is this possible with FlexSearch?

daviddean99 commented 4 years ago

On a related note, I've noticed that in sorting the results for keyword "recruiter", it lists a exact matching job title "recruiter" first, but after that it seems to list additional job titles containing the keyword "recruiter at random.

Is it possible to sort results so that results are ordered by how far from the start of the results the keyword presents?

For example, current behaviour:

Search term: "recruiter" provides results:

"Recruiter"
"Employment Recruiter"
"Blood Donor Recruiter Supervisor"
"Executive Recruiter"
"Personnel Recruiter"
"HR Recruiter (Human Resources Recruiter)"
"Job Recruiter"

If results could be ordered by distance from start of record then it would look something like this:

Search term: "recruiter" should provide results:

"Recruiter"  <----- Exact match
"HR Recruiter (Human Resources Recruiter)" <--- Next closest match from start of record
"Job Recruiter"
"Executive Recruiter"
"Personnel Recruiter"
"Employment Recruiter"
"Blood Donor Recruiter Supervisor"
ts-thomas commented 3 years ago

Please change over to the version >= 0.7.x, thanks a lot.

ts-thomas commented 3 years ago

Also please consider using the option suggest: true within passed search options.