【问题标题】:elasticsearch, multi_match and filter by dateelasticsearch、multi_match 和按日期过滤
【发布时间】:2019-08-12 17:52:21
【问题描述】:

似乎我遵循了我找到的每一个类似的答案,但我就是不知道出了什么问题......

这是一个“匹配所有”查询:

{
    "query": {
        "match_all": {}
    }
}

..和结果:

{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 1,
        "max_score": 1,
        "hits": [
            {
                "_index": "unittest_index_unittestdocument",
                "_type": "unittestdocument",
                "_id": "a.b",
                "_score": 1,
                "_source": {
                    "id": "a.b",
                    "docdate": "2018-01-24T09:45:44.4168345+02:00",
                    "primarykeywords": [
                        "keyword"
                    ],
                    "primarytitles": [
                        "the title of a document"
                    ]
                }
            }
        ]
    }
}

但是当我尝试用这样的日期过滤它时:

{  
    "query":{
        "bool":{
            "must":{  
                "multi_match":{  
                    "type":"most_fields",               
                    "query":"document",
                    "fields":[ "primarytitles","primarykeywords" ]
                }
            },
            "filter": [
                {"range":{ "docdate": { "gte":"1900-01-23T15:17:12.7313261+02:00" } } }
            ]
        }
    }
}

我的点击率为零...

我尝试关注此https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html 和此filtering by date in elasticsearch,但完全没有成功..

有什么我看不到的区别吗???

请注意,当我删除日期过滤器并在“主要关键字”上添加术语过滤器时,我会得到我想要的结果。唯一的问题是范围过滤器

【问题讨论】:

    标签: elasticsearch filter range


    【解决方案1】:

    显然我的查询没有错误,问题是 docdate 字段不是索引...:/

    不知道为什么我最初跳过索引该字段(我的错误),但我相信弹性应该警告我我正在尝试查询具有“索引:假”的内容 p>

    在我看来,弹性不会在不告知正在发生的事情的情况下返回结果是一个主要问题。我失去了一天阅读我在网上可以找到的所有内容,只是因为我没有从引擎那里得到适当的反馈。

    Fail safe 因为这个原因死了……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多