【query】multi_match question in ES 5.5.0


(方磊) #1

When i try to use "multi_match" in my project.
I find a question what is not in line with my expectations.
first,i post some data to the es cluster as follow:

POST /blogs/blog/1
{
  "title":"elasticsearch match query",
  "descrption":"elasticsearch match query"
}
POST /blogs/blog/2
{
  "title":"elasticsearch match query",
  "descrption":"i am a dog"
}
POST /blogs/blog/3
{
  "title":"i am a dog",
  "descrption":"elasticsearch match query"
}
POST /blogs/blog/4
{
  "title":"i am a dog",
  "descrption":"i am a dog"
}

then , i use the query as follow:

POST /blogs/blog/_search
{
  "query": {
   "multi_match": {
     "query": "elasticsearch match query",
     "fields": ["title","descrption"]
   }
  }
}

the result is :

{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 3,
    "max_score": 1.9646256,
    "hits": [
      {
        "_index": "blogs",
        "_type": "blog",
        "_id": "2",
        "_score": 1.9646256,
        "_source": {
          "title": "elasticsearch match query",
          "descrption": "i am a dog"
        }
      },
      {
        "_index": "blogs",
        "_type": "blog",
        "_id": "1",
        "_score": 0.7594807,
        "_source": {
          "title": "elasticsearch match query",
          "descrption": "elasticsearch match query"
        }
      },
      {
        "_index": "blogs",
        "_type": "blog",
        "_id": "3",
        "_score": 0.7594807,
        "_source": {
          "title": "i am a dog",
          "descrption": "elasticsearch match query"
        }
      }
    ]
  }
}

What i think is that the score of the result (the id=1) should be in the first. But why not ?


(Mark Harwood) #2

If you only have a handful of docs use one shard.


(方磊) #3

I use the default settings , each index has 5 shards....


(方磊) #4

When i add some docs to the index named "blogs" , and update the param "type" to "most_fields",and it works well.
but i think it is strange. Default,the match is not the best result.


(Mark Harwood) #5

The default settings are not tuned for a handful of docs so I'd advise against this for small sets of data.

Like shard numbers, it's hard to predict a default match mode that works in all cases. We don't know in advance if the user typed a search that has words that are part of the same field (e.g. title:global title:warming) or part of different fields (e.g. firstname:john lastname:smith).
The other issue here is that even if we decided the current default mode was not as generally useful as a newer mode we can't just change the current default otherwise we break a lot of applications that might be reliant on the old default.


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.