Querying multiple fields at once

I was just wondering if there is a way to query two fields at the same time.
This is the query I'm using right now

setQuery(QueryBuilders.matchPhraseQuery("message", searchString)).get();

I would also like to add a rangeQuery to only search through the logs after a given date.
Is there a way to run both at the same time ?

I used QueryBuilders.termsQuery("message", searchString) it works.But maybe u need to be careful with analyzer.

Ohh, Actually the code is working fine for quering a single field in the data. I was trying to find a way to query TWO different fields with different searchStrings in a format similar to the one posted below

setQuery(QueryBuilders.matchPhraseQuery("message", searchString)).get();

Maybe you need boolean query and set two filters.

if you want to range date, just do setPostFilter(rangeQuery);

Thanks ... This was exactly what I was looking for

:grinning:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.