Reputation: 3
I have a field that is an array of sentences (string). I'd like to search inside the array if the word is in the sentences.
"fields": {
"title": [
"The book of the world"
]
}
The simple query "book" does not return the expected result:
GET catalog/_search
{
"fields" : "title",
"query":{
"match" : {
"title":"book"
}
}
}
Do you have an idea ?
Upvotes: 0
Views: 1179
Reputation: 14492
The field name in that case is fields.title not title.
Try:
GET catalog/_search
{
"fields" : "fields.title",
"query":{
"match" : {
"fields.title":"book"
}
}
}
Upvotes: 1
Reputation: 22651
You must configure an analyzer before adding data to your index.
The analyzer is the thing that "split" your sentence as token (here: "the" "book" "of" "the" "world" or by removing stop words "book" "world").
Please read documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-analyzers.html
Also pay attention how Elasticsearch deals with array: https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html
Upvotes: 1