Reputation: 9399
I have the following Cloudant search index
"indexes": {
"search-cloud": {
"analyzer": "standard",
"index": "function(doc) {
if (doc.name) {
index("keywords", doc.name);
index("name", doc.name, {
"store": true,
"index": false
});
}
if (doc.type === "file" && doc.keywords) {
index("keywords", doc.keywords);
}
}"
}
}
For some reason when I search for specific phrases, I get an error:
Search failed: field "keywords" was indexed without position data; cannot run PhraseQuery (term=FIRSTWORD)
So If I search for FIRSTWORD SECONDWORD, it looks like I am getting an error on the first word.
NOTE: This does not happen to every search phrase I do.
Does anyone know why this would be happening?
doc.name
and doc.keywords
are just string.
doc.name
is usually something like "2004/04/14 John Doe 1234 Document Folder"
doc.keywords
is usually something random like "testing this again"
And the reason why I am storing name and keywords under the keywords index is because I want anyone to be able to search keywords or name by just typing on string value. Let me know if this is not the best practice.
Upvotes: 0
Views: 614
Reputation: 618
Likely the problem is that some of your documents contain a keywords
field with string values, while other documents contain a keywords
field with a different type, probably an array. I believe that this scenario would result in the error that you received. Can you double check that all of the values for your keywords
fields are, in fact, strings?
Upvotes: 2