Hi there,

I am executing the following query:
{
    "from":0,
    "size":5,
    "explain": "true",
    "query":{
      "bool":{
        "must":[
          {
          "multi_match":{
            "query":"Marco",
            "fields":["FirstName","MiddleName","LastName"],
            "fuzziness":0.6
            }
          }
        ]
      }
    }
  }

As the results are by default sorted by the score,  I thought that would
give me the most matching results first. But the first result is a Marco,
then two Mario and then another Marco:

hits: [
  {
    _shard: 8
    _node: pFk-akByRACHUsGiyVa5UQ
    _index: my_index
    _type: my_type
    _id: 52
    _score: 3.0794415
    _source: {
      LastName: Orozco Arriola
      MiddleName: Antonio
      FirstName: Marco
    },
    _explanation: {
      value: 3.0794415
      description: max of:
      details: [
        {
          value: 3.0794415
          description: weight(FirstName:marco in 4) [PerFieldSimilarity],
result of:
          details: [
            {
              value: 3.0794415
              description: fieldWeight in 4, product of:
              details: [
                {
                  value: 1
                  description: tf(freq=1.0), with freq of:
                  details: [
                    {
                      value: 1
                      description: termFreq=1.0
                    }
                  ]
                }
                {
                  value: 3.0794415
                  description: idf(docFreq=1, maxDocs=16)
                }
                {
                  value: 1
                  description: fieldNorm(doc=4)
                }
              ]
            }
          ]
        }
      ]
    }
  },
  {
    _shard: 9
    _node: pFk-akByRACHUsGiyVa5UQ
    _index: my_index
    _type: my_type
    _id: 114
    _score: 2.9459102
    _source: {
      LastName: Barrios Falla
      MiddleName: Mario
      FirstName: Jorge
    },
    _explanation: {
      value: 2.9459102
      description: max of:
      details: [
        {
          value: 2.9459102
          description: weight(MiddleName:mario^0.8 in 8)
[PerFieldSimilarity], result of:
          details: [
            {
              value: 2.9459102
              description: fieldWeight in 8, product of:
              details: [
                {
                  value: 1
                  description: tf(freq=1.0), with freq of:
                  details: [
                    {
                      value: 1
                      description: termFreq=1.0
                    }
                  ]
                }
                {
                  value: 2.9459102
                  description: idf(docFreq=1, maxDocs=14)
                }
                {
                  value: 1
                  description: fieldNorm(doc=8)
                }
              ]
            }
          ]
        }
      ]
    }
  },
  {
    _shard: 12
    _node: pFk-akByRACHUsGiyVa5UQ
    _index: my_index
    _type: my_type
    _id: 94
    _score: 2.7917595
    _source: {
      LastName: Rivera Cabrera
      MiddleName: Israel
      FirstName: Mario
    },
    _explanation: {
      value: 2.7917595
      description: max of:
      details: [
        {
          value: 2.7917595
          description: weight(FirstName:mario^0.8 in 6)
[PerFieldSimilarity], result of:
          details: [
            {
              value: 2.7917595
              description: fieldWeight in 6, product of:
              details: [
                {
                  value: 1
                  description: tf(freq=1.0), with freq of:
                  details: [
                    {
                      value: 1
                      description: termFreq=1.0
                    }
                  ]
                }
                {
                  value: 2.7917595
                  description: idf(docFreq=1, maxDocs=12)
                }
                {
                  value: 1
                  description: fieldNorm(doc=6)
                }
              ]
            }
          ]
        }
      ]
    },
    {
    _shard: 3
    _node: pFk-akByRACHUsGiyVa5UQ
    _index: my_index
    _type: my_type
    _id: 44
    _score: 2.7047482
    _source: {
      LastName: Lemus Salguero
      MiddleName: Antonio
      FirstName: Marco
    },
    _explanation: {
      value: 2.7047482
      description: max of:
      details: [
        {
          value: 2.7047482
          description: weight(FirstName:marco in 1) [PerFieldSimilarity],
result of:
          details: [
            {
              value: 2.7047482
              description: fieldWeight in 1, product of:
              details: [
                {
                  value: 1
                  description: tf(freq=1.0), with freq of:
                  details: [
                    {
                      value: 1
                      description: termFreq=1.0
                    }
                  ]
                }
                {
                  value: 2.7047482
                  description: idf(docFreq=1, maxDocs=11)
                }
                {
                  value: 1
                  description: fieldNorm(doc=1)
                }
              ]
            }
          ]
        }
      ]
    }
  }
]

Also with the explain function I don't really see what I have to change to
get
- first all exact matches ("Marco")
- then the fuzzier ones ("Mario")
Can you help me there?

Cheers! 



--
View this message in context: 
http://elasticsearch-users.115913.n3.nabble.com/Sort-multi-match-query-by-exact-matches-first-tp4048342.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/1390989961390-4048342.post%40n3.nabble.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to