无法在ElasticSearch中链接match_phrase_prefix

时间:2017-03-20 13:53:57

标签: elasticsearch

我正在尝试链接多个match_phrase_prefix查询,但是 由于某种原因,它不会返回任何结果(也没有错误)。当我尝试的时候 一个match_phrase_prefix一切正常。我使用的是弹性搜索版本2.3,我的查询如下所示:

"query": {
    "bool": {
        "must": [
            {
                "match_phrase_prefix": {
                    "title": "נפ"
                }
            },
            {
                "match_phrase_prefix": {
                    "sub_title": "נפצ"
                }
            }
        ]
    }
}

我对特定索引的映射是:

{
"wcm_articles": {
  "mappings": {
     "article": {
        "properties": {
           "approved_talkbacks_counter": {
              "type": "integer"
           },
           "article_link": {
              "type": "string",
              "index": "not_analyzed"
           },
           "author": {
              "type": "string",
              "analyzer": "hebrew"
           },
           "category_id": {
              "type": "string",
              "index": "not_analyzed"
           },
           "date_updated": {
              "type": "date",
              "format": "date_hour_minute_second"
           },
           "is_old": {
              "type": "boolean"
           },
           "is_promoted": {
              "type": "boolean"
           },
           "is_video": {
              "type": "boolean"
           },
           "last_update_user": {
              "type": "string",
              "index": "not_analyzed"
           },
           "launch_date": {
              "type": "date",
              "format": "date_hour_minute_second"
           },
           "plain_text": {
              "type": "string",
              "analyzer": "hebrew"
           },
           "promotion_notes": {
              "type": "string",
              "index": "not_analyzed"
           },
           "status": {
              "type": "string",
              "index": "not_analyzed"
           },
           "sub_title": {
              "type": "string",
              "analyzer": "hebrew"
           },
           "tags": {
              "type": "string",
              "index": "not_analyzed"
           },
           "title": {
              "type": "string",
              "analyzer": "hebrew"
           },
           "type": {
              "type": "string",
              "index": "not_analyzed"
           },
           "waiting_talkbacks_counter": {
              "type": "integer"
           }
        }
     }
  }

} }

一些示例文档是:

"_index": "wcm_articles",
        "_type": "article",
        "_id": "2828280",
        "_score": 2.5246792,
        "_source": {
           "tags": [],
           "category_id": 3,
           "sub_title": "",
           "promotion_notes": "",
           "is_old": false,
           "last_update_user": "",
           "status": 1,
           "type": "article",
           "plain_text": "",
           "launch_date": null,
           "waiting_talkbacks_counter": 0,
           "approved_talkbacks_counter": 0,
           "is_video": false,
           "article_link": "",
           "date_updated": "2016-12-05T15:12:10",
           "title": "קשישה כבת 80 נפצעה קשה מפגיעת רכב בחולון ",
           "author": "",
           "is_promoted": false

"_index": "wcm_articles",
        "_type": "article",
        "_id": "2829275",
        "_score": 2.1283152,
        "_source": {
           "tags": [],
           "category_id": 3,
           "sub_title": "",
           "promotion_notes": "",
           "is_old": false,
           "last_update_user": "",
           "status": 1,
           "type": "article",
           "plain_text": "",
           "launch_date": null,
           "waiting_talkbacks_counter": 0,
           "approved_talkbacks_counter": 0,
           "is_video": false,
           "article_link": "",
           "date_updated": "2016-12-05T15:12:16",
           "title": "רוכבת אופנוע נפצעה קשה בתאונת דרכים בצומת סירקין בפ\"ת",
           "author": "",
           "is_promoted": false

1 个答案:

答案 0 :(得分:0)

好的,我的问题已经解决了。链接查询没有问题。我没有使用" match_phrase_prefix"正确的方法是,只有当你使用多个单词时才会使用单个单词,对于单个单词而言,正确的查询是为了自动完成搜索的形式(包含单词的一部分和不是一个完整的词)是 - "前缀"。当链接这两者的任何组合并正确使用时 - 根本没有问题。

希望这可以帮助其他有类似问题的人。

相关问题