N
N
Narek2017-08-17 09:38:17
elasticsearch
Narek, 2017-08-17 09:38:17

Why do the same documents have different relevance?

Mapping:

$params = [
            'index' => $config['es']['default_index'],
            'type'  => $config['es']['default_type'],
            'body'  => [
                '_source'    => [
                    'enabled' => true
                ],
                'properties' => [
                    'external_id'             => [
                        'type'  => 'text',
                        'index' => false,
                    ],
                    'item_name'               => [
                        'type'            => 'text',
                        'analyzer'        => 'standard',
                        'search_analyzer' => 'standard',
                        'fielddata'       => true,
                        'term_vector'     => 'with_positions_offsets',
                    ],

                ]
            ]
        ];
        $client->indices()->putMapping($params);

Request:
GET sark/item/_search
{
  "size": 120, 
  "query": {
    "query_string": {
      "fields": ["item_name"], 
      "query": "молоко ультрапастеризованное продукция"
    }
  },
  "highlight": {
    "fields": {
      "item_name": {} 
    }
  }
}

Answer:
{
  "took": 3,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 184,
    "max_score": 23.819998,
    "hits": [
      {
        "_index": "sark",
        "_type": "item",
        "_id": "9d090b20-34c2-429c-855d-07a42c16a131",
        "_score": 23.819998,
        "_source": {
          "external_id": "9d090b20-34c2-429c-855d-07a42c16a131",
          "item_name": "Молоко питьевое коровье ультрапастеризованное"
        }
      },
      {
        "_index": "sark",
        "_type": "item",
        "_id": "69046b91-5c7c-4536-bbe5-ea4ae357f716",
        "_score": 23.169369,
        "_source": {
          "external_id": "69046b91-5c7c-4536-bbe5-ea4ae357f716",
          "item_name": "Молоко питьевое ультрапастеризованное (ультравысокотемпературно-обработанное)"
        }
      },
      {
        "_index": "sark",
        "_type": "item",
        "_id": "325135cd-dda5-4317-897b-5f4aedb43944",
        "_score": 22.506695,
        "_source": {
          "external_id": "325135cd-dda5-4317-897b-5f4aedb43944",
          "item_name": "Молоко и молочная продукция"
        }
      },
      {
        "_index": "sark",
        "_type": "item",
        "_id": "4d07acd6-36d8-4949-907d-7fa147fccfc6",
        "_score": 22.506695,
        "_source": {
          "external_id": "4d07acd6-36d8-4949-907d-7fa147fccfc6",
          "item_name": "Молоко и молочная продукция"
        }
      },
      {
        "_index": "sark",
        "_type": "item",
        "_id": "8436eda6-9faf-41a4-b84e-a964bfd01671",
        "_score": 22.506695,
        "_source": {
          "external_id": "8436eda6-9faf-41a4-b84e-a964bfd01671",
          "item_name": "Молоко и молочная продукция"
        }
      },
      {
        "_index": "sark",
        "_type": "item",
        "_id": "51828aae-754b-4190-b404-e359fd7a6fcf",
        "_score": 22.059921,
        "_source": {
          "external_id": "51828aae-754b-4190-b404-e359fd7a6fcf",
          "item_name": "Молоко и молочная продукция"
        }
      },
      {
        "_index": "sark",
        "_type": "item",
        "_id": "83fb278c-f127-4f2f-a09c-ee4d44f9dff5",
        "_score": 22.059921,
        "_source": {
          "external_id": "83fb278c-f127-4f2f-a09c-ee4d44f9dff5",
          "item_name": "Молоко и молочная продукция"
        }
      },
      {
        "_index": "sark",
        "_type": "item",
        "_id": "97aea5b4-a223-4b14-989f-8a530d76e709",
        "_score": 22.059921,
        "_source": {
          "external_id": "97aea5b4-a223-4b14-989f-8a530d76e709",
          "item_name": "Молоко и молочная продукция"
        }
      },
      {
        "_index": "sark",
        "_type": "item",
        "_id": "b74ab5af-f694-43f3-9f53-f06c9887cd0d",
        "_score": 22.059921,
        "_source": {
          "external_id": "b74ab5af-f694-43f3-9f53-f06c9887cd0d",
          "item_name": "Молоко и молочная продукция"
        }
      },
      {
        "_index": "sark",
        "_type": "item",
        "_id": "c86cfbc5-bffb-4fd6-a4b4-77911f8ec85d",
        "_score": 22.059921,
        "_source": {
          "external_id": "c86cfbc5-bffb-4fd6-a4b4-77911f8ec85d",
          "item_name": "Молоко и молочная продукция"
        }
      }
    ]
  }
}

Documents "Milk and dairy products" have different weights - Why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2017-08-17
@RidgeA

Perhaps this
https://www.elastic.co/guide/en/elasticsearch/refe...
will help find the answer to this question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question