I try to implement full text search.
I have a question related to this subject.
I want to at search time, when i search a text, for example "Hello Saeed", return result only when all tokens of that text exist in a message.
this means in "Hello Saeed" that contains "Hello" and "Saeed" tokens just must be return messages that exist both of the words not one of them.
Hello I am Saeed ---> must be return
Hello I am Mike ---> must not be return (because at search time i searched "Hello Saeed" and 'Saeed' not exist in this sentence)
but for search "Hello" both of the previous sentences are approve.
finally my question is, how can i force text analyzer at search time to find all tokens are exist in search text?
My query is
GET /message/_search
{
"from": 0,
"size": 10,
"sort": {
"@timestamp": "desc"
},
"query": {
"bool": {
"must": [
{
"terms": {
"roomId": [
1,
2
]
}
},
{
"match": {
"message": "Hello Saeed"
}
},
{
"match": {
"type": 0
}
},
{
"range": {
"@timestamp": {
"gte": 1000
}
}
}
]
}
}
}
what i know, minimum_should_match use for define minimum number should be match in list of match case.
but in my question i want to force tokens existence that exist in a text message in ONE match item not multiple. so seems to minimum_should_match is not useful here.
It is an option for your match query.
operator in match query is exactly my answer.
"operator = and" force match query to find all tokens that created previously by tokenizer in message analyzer
thanks