可以进行多字段范围查询吗?

时间:2015-05-20 19:56:51

标签: elasticsearch nest elasticsearch-net

我想针对多个字段或带有后缀的字段执行范围查询,例如markups.*。似乎没有办法在NestElasticsearch中执行此操作。例如,ES中的此查询返回结果:

{
  "query": {
    "range": {
        "markups.1": {
          "gte": "2015-01-01T00:00:00.000",
          "lte": "2015-05-20T10:49:07.608"
        }
      }
  }
}

但是这个后缀查询不会返回任何内容:

{
  "query": {
    "range": {
        "markups.*": {
          "gte": "2015-01-01T00:00:00.000",
          "lte": "2015-05-20T10:49:07.608"
        }
      }
  }
}

编辑1,这是该字段的默认映射:

"markups": {
"properties": {
"1": {
"type": "date",
"format": "dateOptionalTime"
}
}
}

编辑2,完成例外:

"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[UNsBpzvUT0eRh455sPvFoA][nyc01check-20150520-170219][0]: RemoteTransportException[[Caregiver][inet[/192.168.2.223:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[nyc01check-20150520-170219][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\ \ \"query\": {\ \ \"query_string\": {\ \ \"fields\": [\"markups.*\"], \ \ \"query\": \"[2015-01-01 TO 2015-05-20]\"\ \ }\ \ }\ \ }]]]; nested: NumberFormatException[For input string: \"2015-01-01\"]; }{[bZjjVX5zTGKDkfTsSU0lIg][nyc01check-20150520-170219][1]: RemoteTransportException[[Payback][inet[/192.168.2.227:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[nyc01check-20150520-170219][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\ \ \"query\": {\ \ \"query_string\": {\ \ \"fields\": [\"markups.*\"], \ \ \"query\": \"[2015-01-01 TO 2015-05-20]\"\ \ }\ \ }\ \ }]]]; nested: NumberFormatException[For input string: \"2015-01-01\"]; }{[pzbyI5Y_TvyzL-tpZGN1HQ][nyc01check-20150520-170219][2]: RemoteTransportException[[Living Monolith][inet[/192.168.2.224:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[nyc01check-20150520-170219][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\ \ \"query\": {\ \ \"query_string\": {\ \ \"fields\": [\"markups.*\"], \ \ \"query\": \"[2015-01-01 TO 2015-05-20]\"\ \ }\ \ }\ \ }]]]; nested: NumberFormatException[For input string: \"2015-01-01\"]; }{[bZjjVX5zTGKDkfTsSU0lIg][nyc01check-20150520-170219][3]: RemoteTransportException[[Payback][inet[/192.168.2.227:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[nyc01check-20150520-170219][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\ \ \"query\": {\ \ \"query_string\": {\ \ \"fields\": [\"markups.*\"], \ \ \"query\": \"[2015-01-01 TO 2015-05-20]\"\ \ }\ \ }\ \ }]]]; nested: NumberFormatException[For input string: \"2015-01-01\"]; }{[aoWs6XiITJGkBXCLog6eNA][nyc01check-20150520-170219][4]: RemoteTransportException[[Nomad][inet[/192.168.2.226:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[nyc01check-20150520-170219][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\ \ \"query\": {\ \ \"query_string\": {\ \ \"fields\": [\"markups.*\"], \ \ \"query\": \"[2015-01-01 TO 2015-05-20]\"\ \ }\ \ }\ \ }]]]; nested: NumberFormatException[For input string: \"2015-01-01\"]; }]",
"status": 400

1 个答案:

答案 0 :(得分:0)

对于此用途query_string

{
  "query": {
    "query_string": {
      "fields": ["markups.*"], 
      "query": "[2015-01-01T00:00:00.000 TO 2015-05-20T10:49:07.608]"
    }
  }
}