-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use extractField to extract document id field #59
Comments
@mquinn-leverege thanks for reporting this. Yes, I agree that it would be nice to be able to tread the |
Hi @mquinn-leverege , this issue is resolved by this commit, now the ID field is consistent with the other fields, and its extraction can be customized with This change is already released as part of version |
@lucaong I have a project where I have no uniq field but I could have a uniq string by combining three fields. Could I do something like idField: ['field1', 'field2', 'field3'] or function join(...strings) {
return strings.join('')
}
...
idField: join('field1', 'field2', 'field3') or create a virtual field with |
Hi @noraj , const miniSearch = new MiniSearch({
fields: […],
extractField: (document, fieldName) => {
if (fieldName === 'id') {
return `#{document.field1}-#{document.field2}`
} else {
return document[fieldName]
}
}
}) In the example above, the ID field is composed by joining two other fields. |
Thanks it works well const miniSearch = new MiniSearch({
fields: […],
extractField: (document, fieldName) => {
if (fieldName === 'id') {
return `${document.field1}-${document.field2}`
} else {
return document[fieldName]
}
}
}) |
PS: It could be nice to create a expo gallery in the documentation or github wiki to link projects using minisearch so people could look at real-life/production examples. |
I've found that using a document structure with an id that is nested, like this for example where
tracker.id
is the document id:is not possible. I'm not sure if there are other considerations preventing this, but it seems as if using extractField to extract the idField in addition to regular fields might solve the issue. I would like to avoid changing the document structure if possible.
The text was updated successfully, but these errors were encountered: