fergiemcdowall / search-index

A persistent, network resilient, full text search library for the browser and Node.js
MIT License
1.39k stars 149 forks source link

How to index and search emails and UUIDs correctly #540

Closed elega9t closed 3 years ago

elega9t commented 3 years ago

Hi,

I have documents that have email and uuids as field values. When I search by email, there are no results returned, same with searching by uuid.

I checked the documentation and didn't find a reference to how to achieve this in search-index.

Thanks

fergiemcdowall commented 3 years ago

That should definitely work- could you post your code?

elega9t commented 3 years ago

Update the query in https://github.com/fergiemcdowall/search-index-issue-537 returns 0 results

console.log(JSON.stringify(await QUERY({
  OR: ['dchaudron0@gravatar.com']
}), null, 2))
fergiemcdowall commented 3 years ago

This has to do with the way the indexer works- it strips out all of the non-alphanumeric characters such that dchaudron0@gravatar.com becomes dchaudron0gravatarcom.

The easiest way to fix this is to change the json file to pass the email as an array email: ["dchaudron0@gravatar.com"]. This forces search-index to skip tokenisation, and you should then be able to search for "dchaudron0@gravatar.com" and get hits.

elega9t commented 3 years ago

Great, thanks. It would be useful to be able to control tokenisation per field.