elasticsearch 在Elasticsearch中使用regexp搜索关键字,elasticsearch,elasticsearch" /> elasticsearch 在Elasticsearch中使用regexp搜索关键字,elasticsearch,elasticsearch" />

elasticsearch 在Elasticsearch中使用regexp搜索关键字

elasticsearch 在Elasticsearch中使用regexp搜索关键字,elasticsearch,elasticsearch,下面是我的文档,我想使用以下正则表达式搜索“可用性”值: "regexp" : { "availability": { "value": "2014-*-10" } } 我的文件: { "_index": "testing", "_type": "test", "_id": "1", "_version": 1, "exists": true, "_source": { "id": 1, "title": "

下面是我的文档,我想使用以下正则表达式搜索“可用性”值:

"regexp" : { 
    "availability": {
    "value": "2014-*-10"
    }
}
我的文件:

{
   "_index": "testing",
   "_type": "test",
   "_id": "1",
   "_version": 1,
   "exists": true,
   "_source": {
      "id": 1,
      "title": "Test",
      "availability": {
         "2014-02-15": {
            ["1", "2"]
         },
         "2014-02-14": {
            ["1", "2", "3"]
         },
         "2014-03-15": {
            ["1"]
         },
         "2014-03-14": {
            ["1", "2", "3"]
         }
      }
   }
}
如何在正常值(而非数组)中搜索键(regex)?

解决方案是使用带有*通配符的“default_field”,如以下或类似组合:

{
   "query" : {
        "query_string": {
            "default_field": "availability.2014-*-13.*",
            "query": "1"
        }

    }
}

你说的正则表达式到底是什么意思?无论如何,在elasticsearch中使用正则表达式是没有意义的。我需要搜索所有匹配[“可用性”][“2014-*-15”]的文档,因为可能会有更多的文档。这对你有帮助吗?@phoet你也许应该读一些@mconlin你是对的,我以前没用过。谢谢你的指点。@mconlin我笑了