2016-07-25 54 views
0

我有以下查询运行,但不会返回正确的结果。返回的结果全部不包含查询中请求的单词(不包含请求的单词)。它可能与查询的“字段”部分有关,但如果没有匹配,它不应该返回任何内容吗?elasticsearch全文搜索所有字段的开始和结束时间

{ 
"fields": ["id", "author", "authorId"], 
"query": { 
    "bool": { 
     "must": [{ 
      "match": { 
       "content": "dog" 
      } 
     }], 
     "filter": [{ 
      "term": { 
       "sourceOriginator": "Twitter" 
      } 
     }, { 
      "range": { 
       "estimatedDate": { 
        "gte": "2016-07-24T18:14:36.000Z", 
        "lte": "2016-07-25T18:14:38.000Z" 
       } 
      } 
     }] 
    } 
} 
} 
+0

什么是你使用的“内容”字段仪? – rajat

+0

我不知道“分析仪”是什么。 –

+0

为了更好地理解和使用Elasticsearch,我推荐阅读参考文档或由Elasticsearch开发人员撰写的免费在线图书:https://www.elastic.co/guide/en/elasticsearch/guide/2.x/index。 HTML。知道什么是“分析器”,对理解Elasticsearch至关重要。 –

回答

0

做到这一点,正确的方法是使用multi_match

{ 
"fields": ["id", "author", "authorId"], 
"query": { 
    "bool": { 
     "must": [{ 
      "multi_match": { 
       "query": "dog", 
       "fields": ["id", "author", "authorId","content"] 
      } 
     }], 
     "filter": [{ 
      "term": { 
       "sourceOriginator": "Twitter" 
      } 
     }, { 
      "range": { 
       "estimatedDate": { 
        "gte": "2016-07-24T18:14:36.000Z", 
        "lte": "2016-07-25T18:14:38.000Z" 
       } 
      } 
     }] 
    } 
} 
} 
相关问题