-
Notifications
You must be signed in to change notification settings - Fork 149
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
Can't seem to get results when searching for indexed text #234
Comments
Hmmm- you definitely have a document in the index, and your query syntax seems to be OK (disclaimer: might be missing something- have not had morning coffee yet). This means that there may be something unusual about the way you are indexing it. The examples and tests should provide some clues. If you can post a test case which indexes the document and reproduces the error, then we can fix it for you. |
@fergiemcdowall Well, all my code is hosted here if you want to take a look at it: https://github.com/joshterrill/doc-search |
Your code looks OK, there are no obvious errors. We can only really look at contained test cases. If you can throw one together, we can fix it for you. Or you might find out what the problem is in the process of making the test case :) |
I'm not really sure how to create a test case. But I'll look into this stuff again. |
Okay, something is not right here. I created a route that basically just creates a simple object and pushes that through:
And when I go to search it with:
I still get 0 results.... |
I even followed this quickstart guide verbatim and can't get it to return results... https://github.com/fergiemcdowall/search-index/blob/master/doc/quickstart.md |
Hey there, I believe I'm running into a very similar problem as joshterrill. I'm indexing a document (markdown syntax) with the fields "title" and "body", then searching for it like so: q.query = {
"title": searchString.split(" "),
"body" : searchString.split(" ")
}; However it only ever seems to return results if the string matches exactly with a word in the title. Update If I use the query: q.query = {
"*": searchString.split(" ")
}; It works fine (ie: it finds occurrences of the search terms in the body). Is something wrong with our query syntax for searching on multiple fields? Am I correct in assuming that searching on fields behaves like an OR rather than an AND? |
I can't even get anything to return, even if I match a word exactly as it
|
Try wrapping your object in an array: var pushObject = [{"test": "123", "test2": "456"}]; Also, it's good practice to empty the index before adding stuff in (if you only add stuff once)... just incase: function addStuffToIndex(si, stuff, callback) {
si.empty( function(err) {
if (err){
callback(err)
}
else{
si.add(stuff, function(err) {
if (err) {
callback(err)
}
else{
callback(null)
}
});
}
});
} |
Still does not work.
|
Try downgrading to search-index 0.6.15? You'll have to delete the module from Try changing your initialization options to this as well: var siOptions = {
indexPath: 'si',
fieldsToStore: 'all'
} If neither of those work I'll fork your repo and give it a whirl tomorrow. Besides the other issue I'm facing, everything else works great for me. Pro Tip: Syntax highlight your code like this:
|
@ethanrubinson yes, you need to arrayify search terms like so: q.query = {
"body": ['donald', 'duck'] // return documents containing either 'donald' or 'duck'
}; ...so that you can do phrase search like so (if you have indexed with ngrams of 2 or more): q.query = {
"body": ['donald duck'] // returns documents with the phrase 'donald duck'
}; And yes, emptying before reindexing is faster. FYI |
@ethanrubinson I tried downgrading and still no luck. I'm not sure what's
|
I am arrayify-ing the search terms: In other words, if I search on fields 'title', and 'body', for the word "App", does "App" need to show up in both the title and the body for the doc to be returned... or just in one? Yes, I can get the quickstart to work. Try it on another machine maybe? A vanilla Amazon EC2 instance would work fine |
If I understand you correctly: both each |
@joshterrill I will try to post a gist to get you started if I get time today |
I'm searching for "*":["test"] which is a word that I have stored in my
|
@fergiemcdowall Ah, yes that is exactly what I was asking. I'm going to submit a PR for your search.md doc, it's not clear on there if that was the case 👍 Thanks! |
@fergiemcdowall thanks!
|
I actually just got this to work. I have no idea what I did wrong, but it had something to do with the si options that I had set. And I used the options that were recommended in the docs. Here's what I had:
I deleted all of the options except |
👍 |
Could you explain why those options weren't yielding any results? I'm confused by it a tad. |
The code snippets you have posted look fine, and should work. Maybe you have found a bug. We would love to get reproducible test case (a simple script that |
Okay I'll write a test case tomorrow and see what I come up with. |
Just saw a possible error in your siOptions, @joshterrill. Not sure if your
|
|
Ok, from what I remember, this is what happened when just using a single integer higher than 1. Matcher worked, search not. But something in the code may have changed? |
I'm trying to write something where I can upload a document, grab the text out of the document and store the text (and filename and mimetype) in search-index.
I've stored a document just fine, but when I go to search through text in it, nothing seems to ever come up.
So when I put wildcards (
*
) in both the search fields, I get the document that I have stored in the database:But when I search for a word that is inside the
text
field, like the word "traditional", I get no results:The text was updated successfully, but these errors were encountered: