Facebooktwittergoogle_plusredditpinterestlinkedinmail

Terms query in elasticsearch allows us to search multiple terms in content. If you want to implement restriction whether one term, two terms or all terms should match, then you can use minimum_match in elasticsearch query . For Example : If we want to search documents which is belongs in “mobile” and “mobile-accessories” category then elasticsearch query DSL look like below.

{
    "query": {
        "terms": {
            "category": [
                "mobile",
                "mobile-accessories"
            ],
            "minimum_match": 1
        }
    }
}

The Above query returns all the document which is belongs to one or both categories. Because we have set the minimum_match to 1 here. If we want the query to match all categories, we set the minimum_match property to 2.

Minimum Match in Elasticsearch Query DSL Roopendra DevOPSElasticsearch,
Terms query in elasticsearch allows us to search multiple terms in content. If you want to implement restriction whether one term, two terms or all terms should match, then you can use minimum_match in elasticsearch query . For Example : If we want to search documents which is belongs...
Terms query in elasticsearch allows us to search multiple terms in content. If you want to implement restriction whether <em>one term, two terms or all terms</em> should match, then you can use minimum_match in elasticsearch query . For Example : If we want to search documents which is belongs in "<strong>mobile</strong>" and "<strong>mobile-accessories</strong>" category then <strong>elasticsearch query DSL</strong> look like below. <pre><code>{     "query": {         "terms": {             "category": [                 "mobile",                 "mobile-accessories"             ],             "minimum_match": 1         }     } } </code></pre> The Above query returns all the document which is belongs to one or both categories. Because we have set the <strong>minimum_match</strong> to 1 here. If we want the query to match all categories, we set the <strong>minimum_match</strong> property to 2.
(Visited 799 times, 30 visits today)
Facebooktwittergoogle_pluslinkedinrss