yahia
(yahia)
April 29, 2013, 2:44pm
1
Hi all,
I want to create PhraseQuery for two fields as follows:
QueryBuilder queryBuilder1 =
QueryBuilders.matchPhraseQuery(field1,termExact);
QueryBuilder queryBuilder2 =
QueryBuilders.matchPhraseQuery(field2,termExact);
I want my query returning documents that contain the termExact in field1 or
field2;
how I can proceed,
-Yahia AMMAR
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .
Add queryBuilder1 and queryBuilder2 as should clauses inside a
BoolQueryBuilder, and set minimumShouldMatch to 1.
Something like:
BoolQueryBuilder orQuery = QueryBuilders.boolQuery();
orQuery.should(queryBuilder1);
orQuery.should(queryBuilder2);
orQuery.minimumNumberShouldMatch(1);
Then issue the orQuery.
On Monday, April 29, 2013 10:44:33 AM UTC-4, Ammar Yahia wrote:
Hi all,
I want to create PhraseQuery for two fields as follows:
QueryBuilder queryBuilder1 =
QueryBuilders.matchPhraseQuery(field1,termExact);
QueryBuilder queryBuilder2 =
QueryBuilders.matchPhraseQuery(field2,termExact);
I want my query returning documents that contain the termExact in field1
or field2;
how I can proceed,
-Yahia AMMAR
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .
taras
(Taras Shkvarchuk)
May 1, 2013, 12:24am
3
You will actually get a better performance by using MultiMatchhttp://www.elasticsearch.org/guide/reference/query-dsl/multi-match-query/ query.
{"multi_match":{"fields":["field1","field2"], "type":"phrase", "Great
Phrase"}}
On Monday, April 29, 2013 2:01:13 PM UTC-7, InquiringMind wrote:
Add queryBuilder1 and queryBuilder2 as should clauses inside a
BoolQueryBuilder, and set minimumShouldMatch to 1.
Something like:
BoolQueryBuilder orQuery = QueryBuilders.boolQuery();
orQuery.should(queryBuilder1);
orQuery.should(queryBuilder2);
orQuery.minimumNumberShouldMatch(1);
Then issue the orQuery.
On Monday, April 29, 2013 10:44:33 AM UTC-4, Ammar Yahia wrote:
Hi all,
I want to create PhraseQuery for two fields as follows:
QueryBuilder queryBuilder1 =
QueryBuilders.matchPhraseQuery(field1,termExact);
QueryBuilder queryBuilder2 =
QueryBuilders.matchPhraseQuery(field2,termExact);
I want my query returning documents that contain the termExact in field1
or field2;
how I can proceed,
-Yahia AMMAR
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out .