fergiemcdowall on v3.2.0
fergiemcdowall on master
bump node test versions version bump (compare)
fergiemcdowall on master
feat: switch to `abstract-level` fix: install `fergies-inverted-… fix: fix require path for `si` and 4 more (compare)
dependabot[bot] on npm_and_yarn
Bump file-type from 16.5.3 to 1… (compare)
eklem on npm_and_yarn
eklem on master
Bump terser from 5.14.1 to 5.14… Merge pull request #587 from fe… (compare)
:wave: I'm investigating search-index for a library and am wondering how it handles searching in array values, here's the data I'm indexing:
{
"name": "Homer Simposon",
"favoritePosts": [
"content/posts/welcome3.md"
],
"_id": "content/authors/homer.md",
}
And here's my query (sorry for the length):
{
"AND": [
{
"FIELD": [
"favoriteposts"
],
"VALUE": {
"GTE": "contentpostswelcome3md",
"LTE": "contentpostswelcome3md"
}
},
{
"FIELD": [
"name"
],
"VALUE": {
"GTE": "homer",
"LTE": "homer"
}
}
]
}
Without the favoriteposts
portion, things work as expected. I've seen a few things on the Github issues about this but none of them quite seem to match up to my use case
favoriteposts
/ favoritePosts
and contentpostswelcome3md
/content/posts/welcome3.md
)
{
"name": "Homer Simposon",
"favoritePosts.0": "content/posts/welcome3.md",
"favoritePosts.1": "content/posts/welcome4.md",
"_id": "content/authors/homer.md"
}
EDIT: I do get valid results when I don't strip casing and special characters in the VALUE
section, so this works:
{
"AND": [
{
"FIELD": [
"favoriteposts"
],
"VALUE": {
"GTE": "content/posts/welcome3.md",
"LTE": "content/posts/welcome3.md"
}
},
{
"FIELD": [
"name"
],
"VALUE": {
"GTE": "homer",
"LTE": "homer"
}
}
]
}
This is confusing to me because when I don't have an array for favoritePosts
I do need to strip special characters
favoriteposts
finds hits, but favoritePosts
(large 'P') doesn't
caseSensitive: true
then the field name favoritePosts
works as expected
if you initialize search-index with caseSensitive: true then the field name favoritePosts works as expected
Thanks, I'll try that
;(async () => {
const si = require('search-index')
const print = txt => console.log(JSON.stringify(txt, null, 2))
const db = await si({
name: 'arrays'
})
const data = [
{
name: 'Homer Simpson',
favoritePosts: ['content/posts/welcome3.md'],
_id: 'content/authors/homer.md'
}
]
await db.PUT(data)
await db
.QUERY({
FIELD: ['favoriteposts'],
VALUE: 'content/posts/welcome3.md'
})
.then(print)
})()
'content/posts/welcome3.md'
(no array), then special chars will be be stripped and the string will be tokenized
Would
const data = [
{
name: 'Homer Simpson',
favoritePosts: ['content/posts/welcome3.md', 'content/post/welcome4.md'],
_id: 'content/authors/homer.md'
}
]
Be indexed as 'content/posts/welcome3.md'
and 'content/posts/welcome4.md'
as separate fields somehow (sorry, might be a confusing question)
level-out
to inspect the index
search-index@3
(coming soon)
"bøker er gøy"
are not always tokenized correctly
ø
)
['bøker er', 'er gøy']
VALUE: 'another'
comments: ['doh', 'this is another comment']
would allow you to search for VALUE: 'doh'
and VALUE: 'this is another comment'