简体   繁体   中英

ElasticSearch QueryString vs multiple wildcards

Maybe because I'm new to ES but I can't find any documentations that talks about queries and their performance/comparison? How a query like query_string will be parsed/translated?

I'm wondering which is better performance/faster multiple wildcard filter or a string_query?

"query": {
 "bool" : {
  "must" : [
    {
      "query_string" : {
        "query" : "*val1* OR *val2*",
        "default_field" : "field",
        "fields" : [ ],
        "type" : "best_fields",
        "default_operator" : "or",
        "max_determinized_states" : 10000,
        "enable_position_increments" : true,
        "fuzziness" : "AUTO",
        "fuzzy_prefix_length" : 0,
        "fuzzy_max_expansions" : 50,
        "phrase_slop" : 0,
        "escape" : false,
        "auto_generate_synonyms_phrase_query" : true,
        "fuzzy_transpositions" : true,
        "boost" : 1.0
      }
    }
  ],
  "adjust_pure_negative" : true,
  "boost" : 1.0
}

}

Or

"query": {
 "bool" : {
  "filter" : [
    {
      "bool" : {
        "should" : [
          {
            "wildcard" : {
              "field" : {
                "wildcard" : "*val1*",
                "boost" : 1.0
              }
            }
          },
          {
            "wildcard" : {
              "field" : {
                "wildcard" : "*val2*",
                "boost" : 1.0
              }
            }
          }
        ],
        "adjust_pure_negative" : true,
        "boost" : 1.0
      }
    }
  ],
  "adjust_pure_negative" : true,
  "boost" : 1.0
}

}

Got an answer here: https://discuss.elastic.co/t/querystring-vs-multiple-wildcards/335382/4 . Seems like you need to benchmark and decide for yourself!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM