2014-01-19 36 views
0

下面是我的文件,我想搜索值「可用性」使用這樣的正則表達式:搜索鍵

"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"] 
     } 
     } 
    } 
} 

我如何搜索鍵正常值(不是數組)的工作(正則表達式)?

+0

你到底用正則表達式是什麼意思?無論如何,在elasticsearch中使用正則表達式是沒有意義的。 – phoet

+0

我需要搜索所有匹配[「可用性」] [「2014 - * - 15」]的文檔,因爲可能有更多的文檔。這會幫助你嗎? –

+0

@phoet你應該讀一些[doco](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html) – mconlin

回答

1

的解決方案是使用「default_field」用通配符*這樣的或類似的組合:

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

    } 
}