Elastic Search Java API / fieldQuery

Hi, i just checked the java api from elasticsearch. i want to search for logs in elasticsearch which have a specific value in the field "rid". (for example rid=1500B8B179A646F28DA998875530219E.)

i tried this with the follwoing config (.setQuery(fieldQuery....). but what I get back as response are all logs from this index, idenpendent from the rid :-(. the search in kibana works with rid=15... to get just that entries.

Can you help me?

    SearchResponse response = client.prepareSearch("logstash-2016.03.30")
            .setSearchType(SearchType.QUERY_AND_FETCH)
            
            .setTypes("logs")
            .addField("@timestamp")
            .addField("rid")
            .setQuery(fieldQuery("rid", "1500B8B179A646F28DA998875530219E"))
            
            .execute()
            .actionGet();

I think you want to use a termQuery here.

1 Like