tester
tester

Reputation: 23189

Elastic index/search_analyzer match all tokens

In my mapping file for ElasticSearch, for "all", I have index_analyzer and search_analyzer:

{
  "all": {
    "enabled" : true,
    "index_analyzer" : "index_analyzer",
    "search_analyzer" : "search_analyzer"
  }
}

If I search "foo bar" on all, it returns hits for foo OR bar. How would I make this AND by default?

Upvotes: 0

Views: 134

Answers (1)

phoet
phoet

Reputation: 18845

From the documentation of Match Query

The default match query is of type boolean. It means that the text provided is analyzed and the analysis process constructs a boolean query from the provided text. The operator flag can be set to or or and to control the boolean clauses (defaults to or). The minimum number of should clauses to match can be set using the minimum_should_match parameter.

[...]

Here is an example when providing additional parameters (note the slight change in structure, message is the field name):

{
    "match" : {
        "message" : {
            "query" : "this is a test",
            "operator" : "and"
        }
    }
}

Upvotes: 2

Related Questions