I want to search "Marketing in social networks" inside documents. All together. But i continue getting results with words separated. i have the following DSL query:
{
"fields": ["title"],
"query": {
"bool": {
"should": [{
"match": {
"title": "SEO"
}
}],
"must": [{
"match": {
"content": {
"query": "Marketing in social networks",
"operator": "and"
}
}
}]
}
}
}
I do not have documents that contain this phrase and title but i also get results(documents) with the words of the phrase to search splitted. I want a strict search. If there is not any document that have this phrase do not retrieve any document or only retrieve documents with that title. Why operator and does not work?
Can you try like below using type phrase. See here it says,
query first analyzes the query string to produce a list of terms. It then searches for all the terms, but keeps only documents that contain all of the search terms, in the same positions relative to each other
{
"fields": ["title"],
"query": {
"bool": {
"should": [{
"match": {
"title": "SEO"
}
}],
"must": [{
"match": {
"content": {
"query": "Marketing in social networks",
"type": "phrase"
}
}
}]
}
}
}
P.S: I haven't tried it yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With