Elasticsearch查询失败

时间:2016-07-08 21:19:43

标签: angularjs elasticsearch

我使用Elasticsearch和AngularJS构建了一个小型搜索应用。我使用AngularJS UI Bootstrap Typeahead几乎实现了自动完成功能。由于某些原因,搜索功能的ES查询失败... IF 我从自动完成下拉列表中选择了术语。当我输入搜索词并单击搜索时,它可以正常工作。

我使用ES match_phrase_prefix查询进行自动填充,并使用multi-match查询进行实际搜索

HTML看起来像这样

<input type="text" ng-model="searchTerms" class="form-control input-md" placeholder="{{ searchTerms }}" name="srch-term" id="srch-term" uib-typeahead="query as query._source.ymme for query in getSuggestions($viewValue)" typeahead-on-select="search($item)">

typeahead-on-select="search($item)"会对选择执行搜索,那么,如果multi-match查询在自动完成时工作正常,为什么无法解析match_phrase_prefix查询?

更新完成错误消息

    All shards failed for phase: [query_fetch]
org.elasticsearch.search.SearchParseException: [hugetestindex][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"multi_match":{"query":{"fields":["content","title"],"query":{"_index":"hugetestindex","_type":"doc","_id":"22","_score":2.760369,"_source":{"ymme":"bourne supremacy"}},"operator":"and"}}},"size":100,"from":0,"highlight":{"fields":{"title":{"number_of_fragments":0},"content":{"number_of_fragments":10,"fragment_size":300}}}}]]

searchTerms是用户的搜索查询,输入元素上的ng-model。

更新2 我将typeahead-on-select="search($item)"更改为typeahead-on-select="search.searchTerms($item)",这似乎已经处理了我在控制台选项卡中收到的400错误请求错误,但是,查询仍然失败......现在看起来它并没有试图搜索选择......?

这是来自searchService的查询

index: 'hugetestindex',
  body: {
    "query": {
      "multi_match": {
        "query": searchTerms,
        "fields": ["content", "title"],
        "operator": "and"
        }
      },
    size: 100,
    from: 0,
    highlight: {
      fields: {
        "title": {number_of_fragments: 0},
        "content": {number_of_fragments: 10,fragment_size: 300}
      }
    }
  }

0 个答案:

没有答案