Comments (10)
I have the same bug!
To reproduce create documents with multiple attributes.
In the search fields put every attributes.
Then put almost the same data in two differents attributes for 3-4 documents.
Exemple
{ id: 1, name: 'fooA', name2: 'fooA456' }
{ id: 1, name: 'fooA', name2: 'fooA456' }
{ id: 1, name: 'fooA', name2: 'fooA456' }
{ id: 1, name: 'fooE', name2: 'fooA123' }
{ id: 1, name: 'fooF', name2: 'fooA123' }
{ id: 1, name: 'fooG', name2: 'fooA123' }
Now you can type in your search something like this: fooA
You will only get the first block (the 3 elements in my example).
I have the same bug in production but with more data!
Now I am fucked...
from flexsearch.
Please change over to the version >= 0.7.x which solves that issue, thanks a lot.
from flexsearch.
I also encountered other problems which occur when importing large datasets into an index (thus the original title until I discovered that it was unrelated to the size of the dataset), but splitting the index into many smaller indexes seemed to alleviate those problems (and it's still plenty fast!).
from flexsearch.
@stefandesu The issue occurs by using "notation:0
in the field description. Actually array index notation is not supported. But this looks very easy to implement.
To solve this actually you need to serialize the array notation into a string when adding:
let index = new FlexSearch({
doc: {
id: "uri",
field: [
"prefLabel:de",
"editorialNote:de",
"scopeNote:de",
"notation"
]
},
profile: "score"
});
Either:
simple array
concepts.forEach(function(item){
item.notation = item.notation.join(" ");
});
Or:
complex array
concepts.forEach(function(item){
item.notation = JSON.stringify(item.notation);
});
from flexsearch.
@ts-thomas Thanks for your reply, but I think you are wrong. I updated the example above to use a string instead of the array notation (just like you suggested) and it's still happening. Also, you said "array index notation is not supported", but it did work with notation:0
when it was last in the field
array.
Please try the code out. I'm able to reproduce the issue on both my work computer and my personal computer. (I also used ./flexsearch/flexsearch
for the import initially because I was using a fork, but I updated that as well. Sorry about that.)
Edit: I think the array notation (notation:0
) works because in JavaScript, arrays are basically objects, so maybe the feature didn't need to be implemented because it is already inherently supported just like objects.
from flexsearch.
Note that this is still an issue as of FlexSearch 0.6.22 and it's preventing me from giving FlexSearch a serious go for our project. If needed, I can try to provide a PR with tests that demonstrate the problem using a simpler dataset than above.
from flexsearch.
In fact, only the results with the first matching field are returned. If you search "blue"
with indexed fields ["a", "b", "c"]
in [{ id: "1", a:"green", b:"blue", c:"yellow"}, {id: "2", a:"orange", b:"black", c:"blue"}]
you will get only the first item since the first matching field is "b"
and second item field "b"
doesn't match the query.
result[count++] = tmp;
should be added to this line
Line 3473 in a4e6e67
from flexsearch.
@Jay1337 I could not reproduce the issue with your example, but I found out that adding another field to the index (even if that field does not exist in the data) makes it fail:
const FlexSearch = require("flexsearch")
const indexSuccess = new FlexSearch({
doc: {
id: "id",
field: [
"a",
"b",
"c",
]
},
})
const indexFail = new FlexSearch({
doc: {
id: "id",
field: [
"a",
"b",
"c",
"d",
]
},
})
const data = [
{ id: "1", a: "green", b: "blue", c: "yellow" },
{ id: "2", a: "orange", b: "black", c: "blue" },
]
indexSuccess.add(data)
indexFail.add(data)
let results
results = indexSuccess.search("blue")
console.log(results)
// Prints out two results as expected.
results = indexFail.search("blue")
console.log(results)
// Prints only one result -> bug!
Unfortunately, adding your fix doesn't change this, so the bug must be somewhere else.
In addition to that, I found out that if you try to index a field that is not available on all items in the data, FlexSearch will throw an error. I created a new issue for this: #122
from flexsearch.
Happens to me as well. When the first field matches, the following ones aren't considered at all.
from flexsearch.
I just updated my original issue so that it can be executed with version 0.6.32. Unfortunately, I wasn't able to get Flexsearch running at all with the upcoming version 0.7.0 in Node: "ReferenceError: window is not defined"
from flexsearch.
Related Issues (20)
- new Document causes `.default is not a constructor` error HOT 1
- Benchmark link is broken HOT 1
- Setting a string as "encode" doesn't work (confusing document?) HOT 1
- How to return context (+ or - few lines) around the hits of given search text
- Enriched document search showing duplicate results
- I have a question about how the results are sorted HOT 2
- Do not force string in Index#add() when custom encoder
- "Document Indexes" link in readme is broken
- Typo in cdn link
- TypeScript doesn't allow omitting id from the document descriptor while the README says it is allowed
- document search option "pluck" is rejected by TypeScript
- Some documents may appear multiple times in the search result
- Error: export 'Document' (imported as 'Document') was not found in 'flexsearch' (possible exports: default) HOT 2
- Add French language pack HOT 1
- return one if exact match? HOT 1
- Having issue indexing entry with symbols/ special characters
- Is there a way to create an offline index in PHP or Python?
- 咨询检索配置(缓存值: "多大的;多少平" 使用:search("是多少平的") 没有返回结果,想要可以返回应该怎么做呢)
- Results Not Sorted by Relevance for Simple Queries Using match Preset
- Issue with types in multi field search for a document index
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexsearch.