2016-09-21 64 views
0

完全一致我試圖根據域名過濾日誌。例如,我只想要域的結果:bh250.example.com。Ealasticsearch的結果與參數

當我使用下面的查詢:

http://localhost:9200/_search?pretty&size=150&q=domainname=bh250.example.com

第3分的結果有一個域名:bh250.example.com在具有bh500.example.com 4

我已閱讀關於如何查詢Elasticsearch的幾篇文檔,但我似乎錯過了一些東西。我只想要與參數100%匹配的結果。

更新!距離Val

queryFilter = Q("match", domainname="bh250.example.com") 

search=Search(using=dev_client, index="logstash-2016.09.21").query("bool", filter=queryFilter)[0:20] 

回答

0

你幾乎沒有問題後,你只需要做出一個小的變化:

http://localhost:9200/_search?pretty&size=150&q=domainname:"bh250.example.com" 
                 ^    ^
                  |     | 
            use colon instead of equal... and double quotes 
+0

有沒有辦法增加結腸和蟒蛇elasticsearch DSL – JasperFennet

+0

如何內部的雙引號你現在在做嗎? – Val

+0

更新的問題與我現在使用的代碼 – JasperFennet