elasticsearch不考虑#标签

时间:2019-03-14 20:58:37

标签: node.js elasticsearch

我通过aws lambda nodejs服务使用elasticsearch插件:

https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/quick-start.html

一切正常。 我是新手,仍在学习。'这是我的查询:

        requestBody = elasticSearchBuilder.requestBodySearch()
        .query(
            elasticSearchBuilder.boolQuery()
                .must(elasticSearchBuilder.multiMatchQuery(fields, "#test")
                    .type(sortAlgorithm)
                    .tieBreaker(tieBreaker)
                    .minimumShouldMatch(searchAccuracySent))
                .must(elasticSearchBuilder.matchQuery("enabled", "1"))
                .filter(elasticSearchBuilder.rangeQuery(dateTimeFieldRangeCheck).gt(dateFrom))
                .filter(elasticSearchBuilder.rangeQuery(dateTimeFieldRangeCheck).lt(dateTo))
        ).sort(elasticSearchBuilder.sort(dateTimeFieldRangeCheck,"desc"))

问题是无论我搜索测试还是#test,上面的查询仅返回与测试相关的结果。 因此,显然它没有考虑#。

我很高兴有人能帮助我

更新:

这是我的纯ES查询:

{
"query": {
    "bool": {
        "must": [
            {
                "multi_match": {
                    "query": "#test",
                    "fields": [
                        "channel_name",
                        "owner",
                        "owner_channel",
                        "byline_name",
                        "byline_publication",
                        "headline",
                        "seo_terms",
                        "category",
                        "body",
                        "pull_quote"
                    ],
                    "type": "best_fields",
                    "tie_breaker": 0.3
                }
            },
            {
                "match": {
                    "enabled": "1"
                }
            }
        ],
        "filter": [
            {
                "range": {
                    "publish_datetime": {
                        "gt": "2013-02-28 23:59:16"
                    }
                }
            },
            {
                "range": {
                    "publish_datetime": {
                        "lt": "2020-02-28 23:59:16"
                    }
                }
            }
        ]
    }
},
"sort": [
    {
        "publish_datetime": "desc"
    }
  ]
 }

0 个答案:

没有答案