2014-11-05 259 views
0

我执行这个查询弹性的搜索查询不返回结果时,现场有双引号

POST /_search { 
    "query":{ 
    "filtered":{ 
     "filter":{ 
     "bool":{ 
      "must":[ 
      { 
       "term":{ 
       "tpid":3 
       } 
      }, 
      { 
       "term":{ 
       "eapid":0 
       } 
      } 
      ] 
     } 
     } 
    } 
    } 
} 

我得到导致这样

{ 
    "took": 2, 
    "timed_out": false, 
    "_shards": { 
    "total": 20, 
    "successful": 20, 
    "failed": 0 
    }, 
    "hits": { 
    "total": 10633, 
    "max_score": 1, 
    "hits": [ 
     { 
     "_index": "gss.aggregated.se.logstash-2014.11.04", 
     "_type": "gss.aggregated.se", 
     "_id": "v63uksmIRgG9bI5hgS5DIQ", 
     "_score": 1, 
     "_source": { 
      "blacklistAggregatedKey": { 
      "utcTimestamp": "2014-10-28T09:00", 
      "departureAirport": "OVB", 
      "arrivalAirport": "KRR", 
      "tpid": 3, 
      "eapid": 0, 
      "AdvancePurchaseWindow": 3, 
      "LengthOfStay": -1 
      }, 
      "blacklistAggregatedValue": { 
      "searchCount": 1, 
      "blackListed": 0 
      }, 
      "@version": "1", 
      "@timestamp": "2014-11-04T19:30:16.426Z", 
      "type": "gss.aggregated.se" 
     } 
     }, 
     { 
     "_index": "gss.aggregated.se.logstash-2014.11.04", 
     "_type": "gss.aggregated.se", 
     "_id": "bu7I38_CRDG17sXVq3IR-g", 
     "_score": 1, 
     "_source": { 
      "blacklistAggregatedKey": { 
      "utcTimestamp": "2014-10-28T09:00", 
      "departureAirport": "OSL", 
      "arrivalAirport": "OSA", 
      "tpid": 3, 
      "eapid": 0, 
      "AdvancePurchaseWindow": 149, 
      "LengthOfStay": -1 
      }, 
      "blacklistAggregatedValue": { 
      "searchCount": 1, 
      "blackListed": 0 
      }, 
      "@version": "1", 
      "@timestamp": "2014-11-04T19:30:16.486Z", 
      "type": "gss.aggregated.se" 
     } 
     }, 
     { 
     "_index": "gss.aggregated.se.logstash-2014.11.04", 
     "_type": "gss.aggregated.se", 
     "_id": "wWb9xFpuRASTWyaqm-q9Kw", 
     "_score": 1, 
     "_source": { 
      "blacklistAggregatedKey": { 
      "utcTimestamp": "2014-10-28T09:00", 
      "departureAirport": "OSL", 
      "arrivalAirport": "NYC", 
      "tpid": 3, 
      "eapid": 0, 
      "AdvancePurchaseWindow": 49, 
      "LengthOfStay": -1 
      }, 
      "blacklistAggregatedValue": { 
      "searchCount": 1, 
      "blackListed": 0 
      }, 
      "@version": "1", 
      "@timestamp": "2014-11-04T19:30:16.491Z", 
      "type": "gss.aggregated.se" 
     } 
     }, 
     { 
     "_index": "gss.aggregated.se.logstash-2014.11.04", 
     "_type": "gss.aggregated.se", 
     "_id": "c1ULKWyhR0iYmaZ5unafKA", 
     "_score": 1, 
     "_source": { 
      "blacklistAggregatedKey": { 
      "utcTimestamp": "2014-10-28T09:00", 
      "departureAirport": "OSL", 
      "arrivalAirport": "MOW", 
      "tpid": 3, 
      "eapid": 0, 
      "AdvancePurchaseWindow": 16, 
      "LengthOfStay": -1 
      }, 
      "blacklistAggregatedValue": { 
      "searchCount": 1, 
      "blackListed": 0 
      }, 
      "@version": "1", 
      "@timestamp": "2014-11-04T19:30:16.495Z", 
      "type": "gss.aggregated.se" 
     } 
     }, 
     { 
     "_index": "gss.aggregated.se.logstash-2014.11.04", 
     "_type": "gss.aggregated.se", 
     "_id": "BGuGnuXsSne6jB7_ith5Lg", 
     "_score": 1, 
     "_source": { 
      "blacklistAggregatedKey": { 
      "utcTimestamp": "2014-10-28T09:00", 
      "departureAirport": "OSL", 
      "arrivalAirport": "MEL", 
      "tpid": 3, 
      "eapid": 0, 
      "AdvancePurchaseWindow": 10, 
      "LengthOfStay": -1 
      }, 
      "blacklistAggregatedValue": { 
      "searchCount": 2, 
      "blackListed": 0 
      }, 
      "@version": "1", 
      "@timestamp": "2014-11-04T19:30:16.505Z", 
      "type": "gss.aggregated.se" 
     } 
     }, 
     { 
     "_index": "gss.aggregated.se.logstash-2014.11.04", 
     "_type": "gss.aggregated.se", 
     "_id": "lHXm68TTTPG44dIskGCr-w", 
     "_score": 1, 
     "_source": { 
      "blacklistAggregatedKey": { 
      "utcTimestamp": "2014-10-28T09:00", 
      "departureAirport": "OSA", 
      "arrivalAirport": "STO", 
      "tpid": 3, 
      "eapid": 0, 
      "AdvancePurchaseWindow": 12, 
      "LengthOfStay": -1 
      }, 
      "blacklistAggregatedValue": { 
      "searchCount": 1, 
      "blackListed": 0 
      }, 
      "@version": "1", 
      "@timestamp": "2014-11-04T19:30:16.606Z", 
      "type": "gss.aggregated.se" 
     } 
     }, 
     { 
     "_index": "gss.aggregated.se.logstash-2014.11.04", 
     "_type": "gss.aggregated.se", 
     "_id": "DewbkMq0Q22IsReLTRIXww", 
     "_score": 1, 
     "_source": { 
      "blacklistAggregatedKey": { 
      "utcTimestamp": "2014-10-28T09:00", 
      "departureAirport": "OSA", 
      "arrivalAirport": "NYC", 
      "tpid": 3, 
      "eapid": 0, 
      "AdvancePurchaseWindow": 3, 
      "LengthOfStay": -1 
      }, 
      "blacklistAggregatedValue": { 
      "searchCount": 1, 
      "blackListed": 0 
      }, 
      "@version": "1", 
      "@timestamp": "2014-11-04T19:30:16.623Z", 
      "type": "gss.aggregated.se" 
     } 
     }, 
     { 
     "_index": "gss.aggregated.se.logstash-2014.11.04", 
     "_type": "gss.aggregated.se", 
     "_id": "tuCl1rEcT4W3dJ9Am-XvSw", 
     "_score": 1, 
     "_source": { 
      "blacklistAggregatedKey": { 
      "utcTimestamp": "2014-10-28T09:00", 
      "departureAirport": "OSA", 
      "arrivalAirport": "MEL", 
      "tpid": 3, 
      "eapid": 0, 
      "AdvancePurchaseWindow": 9, 
      "LengthOfStay": 30 
      }, 
      "blacklistAggregatedValue": { 
      "searchCount": 25, 
      "blackListed": 0 
      }, 
      "@version": "1", 
      "@timestamp": "2014-11-04T19:30:16.625Z", 
      "type": "gss.aggregated.se" 
     } 
     }, 
     { 
     "_index": "gss.aggregated.se.logstash-2014.11.04", 
     "_type": "gss.aggregated.se", 
     "_id": "6-O9T3HuRYuSVD68_cVeCg", 
     "_score": 1, 
     "_source": { 
      "blacklistAggregatedKey": { 
      "utcTimestamp": "2014-10-28T09:00", 
      "departureAirport": "OKC", 
      "arrivalAirport": "PHX", 
      "tpid": 3, 
      "eapid": 0, 
      "AdvancePurchaseWindow": 126, 
      "LengthOfStay": 7 
      }, 
      "blacklistAggregatedValue": { 
      "searchCount": 1, 
      "blackListed": 0 
      }, 
      "@version": "1", 
      "@timestamp": "2014-11-04T19:30:16.787Z", 
      "type": "gss.aggregated.se" 
     } 
     }, 
     { 
     "_index": "gss.aggregated.se.logstash-2014.11.04", 
     "_type": "gss.aggregated.se", 
     "_id": "5_bGAZxdRIy5kAR5XuV70A", 
     "_score": 1, 
     "_source": { 
      "blacklistAggregatedKey": { 
      "utcTimestamp": "2014-10-28T09:00", 
      "departureAirport": "NYC", 
      "arrivalAirport": "QLA", 
      "tpid": 3, 
      "eapid": 0, 
      "AdvancePurchaseWindow": 11, 
      "LengthOfStay": -1 
      }, 
      "blacklistAggregatedValue": { 
      "searchCount": 1, 
      "blackListed": 0 
      }, 
      "@version": "1", 
      "@timestamp": "2014-11-04T19:30:16.862Z", 
      "type": "gss.aggregated.se" 
     } 
     } 
    ] 
    } 
} 

我想通过出发机场进一步筛选这一点。当我尝试

POST /_search 
{ 
    "query": { 
    "filtered": { 
     "filter": { 
     "bool": { 
      "must": [ 
      { 
       "term": { 
       "tpid": 3 
       } 
      }, 
      { 
       "term": { 
       "eapid": 0 
       } 
      }, 
      { 
       "term": { 
       "departureAirport": "\"OVB\"" 
       } 
      } 
      ] 
     } 
     } 
    } 
    } 
} 

我没有得到结果。

+1

你有问题要问? – 2014-11-05 20:59:51

回答

0

提及您使用的映射?运行GET _mapping即可获取。这将有助于调试问题。

但我的直觉是这是一个分析仪问题。必须对字段departureAirport进行分析,以便在索引期间将其值中的双倒数引号剥离。这是默认行为。我的意思是说,字段departureAirport的值为“OVB”(不带引号)索引,而不是“\”OVB \“”(带引号)。这就是为什么你没有得到结果的价值有报价。

+0

谢谢Mouzer的回复。 我最初尝试没有双引号..我没有得到结果,因此这种尝试。 POST/_search {“query”:{“filtered”:{“filter”:{“bool”:{“must”:[{“term”:{“tpid”:3}},{“term” “eapid”:0}},{ “术语”:{ “departureAirport”: “OVB”}} ] } } } } } – 2014-11-07 21:04:35

相关问题