ElasticSearch按短语位置排序

时间:2018-06-09 12:26:04

标签: elasticsearch

我有一个优先级提升的查询,查询工作正常,但结果未排序

square-root

搜索设置:

我使用波斯语分析器和自定义标准化器

{
"query": {
"bool": {
  "should": [
    {
      "bool": {
        "should": [
          {
            "prefix": {
              "subitem.keyword": "i love dogs"
            }
          }
        ],
        "boost": 100
      }
    },
    {
      "bool": {
        "should": [
          {
            "match": {
              "subitem": {
                "query": "i love dogs",
                "operator": "AND"
              }
            }
          }
        ],
        "boost": 10
      }
    },
    {
      "bool": {
        "should": [
          {
            "match_phrase": {
              "subitem": "i love dogs"
            }
          }
        ],
        "boost": 30
      }
    }
  ]
}
},
"size": 30
}

使用关键字字段上的规范化器搜索映射并键入关键字

   "analysis" => [
        "normalizer" => [
          "my_normalizer" => [
            "filter" => [
              "lowercase"
            ],
            "type" => "custom"
          ]
        ],
        "char_filter"=> [
          "zero_width_spaces"=> [
              "type"=>       "mapping",
              "mappings"=> [ "\\u200C=> "] 
          ]
        ],
        "filter"=> [
          "persian_stop"=> [
            "type"=>       "stop",
            "stopwords"=>  "_persian_" 
          ],
        ],
        "analyzer"=> [
          "persian"=> [
            "tokenizer" =>  "standard",
            "char_filter"=> [ "zero_width_spaces" ],
            "filter"=> [
              "lowercase",
              "arabic_normalization",
              "persian_normalization",
              "persian_stop",
            ]
          ],
        ]
      ]

我想按照短语

的位置对结果进行排序

例如"我爱狗"结果必须如下排序:

   "whole_name_fa" => [
            'type' => 'text',
            'analyzer' => 'persian',
            "fields" => [
                "keyword" => [
                  "type" => "keyword",
                  "ignore_above" => 256,
                  "normalizer" => "my_normalizer"
                ]
            ]
        ],

0 个答案:

没有答案