Combining multiple text queries

Hi, I have two different text queries(more specifically of type
phrase_prefix) and each of them individually return what I'm expecting
but I can't figure out how to combine the two..more specifically AND
or OR them. I would also later want to perform this operation on more
than 2 queries. Can you please give me an example of how I should do
this? Also, any links to tutorials on advanced text queries would be
very helpful! Thanks a lot!

Take a look at the Boolean
Query Elasticsearch Platform — Find real-time answers at scale | Elastic
You can use the "must" clause to "AND" queries and the "should" clause to
"OR" them. If you still have a problem with formulating the query, please
post an example of your query that doesn't work so we would understand
better what you have tried to do.

On Friday, May 11, 2012 7:49:21 PM UTC-4, coys wrote:

Hi, I have two different text queries(more specifically of type
phrase_prefix) and each of them individually return what I'm expecting
but I can't figure out how to combine the two..more specifically AND
or OR them. I would also later want to perform this operation on more
than 2 queries. Can you please give me an example of how I should do
this? Also, any links to tutorials on advanced text queries would be
very helpful! Thanks a lot!

On May 14, 7:15 am, Igor Motov imo...@gmail.com wrote:

Take a look at the Boolean
Queryhttp://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
You can use the "must" clause to "AND" queries and the "should" clause to
"OR" them. If you still have a problem with formulating the query, please
post an example of your query that doesn't work so we would understand
better what you have tried to do.

On Friday, May 11, 2012 7:49:21 PM UTC-4, coys wrote:

Hi, I have two different text queries(more specifically of type
phrase_prefix) and each of them individually return what I'm expecting
but I can't figure out how to combine the two..more specifically AND
or OR them. I would also later want to perform this operation on more
than 2 queries. Can you please give me an example of how I should do
this? Also, any links to tutorials on advanced text queries would be
very helpful! Thanks a lot!- Hide quoted text -

  • Show quoted text -

Hello, Thanks for the reply.
Basically, my two queries are :
string query1 = new QueryBuilder()
.Query(qry => qry
.Text(text => text
.Field("field1")
.Query(field1TB.Text)
.Type(TextQueryType.phrase_prefix)
)
).Build();
and string query2 = new QueryBuilder()
.Query(qry => qry
.Text(text => text
.Field("field2")
.Query(field2TB.Text)
.Type(TextQueryType.phrase_prefix)
)
).Build();
I'm using YegoRoff's PlainElastic.Net from github. These two queries
work for me induvidually, but I now want to combine them - I tried,
string query1 = new QueryBuilder()
.Query(qry => qry
.Text(text => text
.Field("field1")
.Query(field1TB.Text)
.Type(TextQueryType.phrase_prefix)
.Field("field2")
.Query(field2TB.Text)
.Type(TextQueryType.phrase_prefix)
.Operator(Operator.AND) // could also be
operator.OR and would like to add multiple fields later on
)
).Build();
but this did not work for me. Also, I'm unable to figure out how to
use a must query, can I pass a text query in there instead of a term?
Thanks!

On May 15, 11:53 am, coys gautam...@gmail.com wrote:

On May 14, 7:15 am, Igor Motov imo...@gmail.com wrote:

Take a look at the Boolean
Queryhttp://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
You can use the "must" clause to "AND" queries and the "should" clause to
"OR" them. If you still have a problem with formulating the query, please
post an example of your query that doesn't work so we would understand
better what you have tried to do.

On Friday, May 11, 2012 7:49:21 PM UTC-4, coys wrote:

Hi, I have two different text queries(more specifically of type
phrase_prefix) and each of them individually return what I'm expecting
but I can't figure out how to combine the two..more specifically AND
or OR them. I would also later want to perform this operation on more
than 2 queries. Can you please give me an example of how I should do
this? Also, any links to tutorials on advanced text queries would be
very helpful! Thanks a lot!- Hide quoted text -

  • Show quoted text -- Hide quoted text -
  • Show quoted text -

Unfortunately, I don't have any experience with YegoRoff's
PlainElastic.Net, so I wouldn't be able to help you here. Have you seen how
Bool Queries are used in tests
https://github.com/Yegoroff/PlainElastic.Net/tree/master/src/PlainElastic.Net.Tests/Builders/Queries/Bool
?

On Tuesday, May 15, 2012 1:54:43 PM UTC-4, coys wrote:

Hello, Thanks for the reply.
Basically, my two queries are :
string query1 = new QueryBuilder()
.Query(qry => qry
.Text(text => text
.Field("field1")
.Query(field1TB.Text)
.Type(TextQueryType.phrase_prefix)
)
).Build();
and string query2 = new QueryBuilder()
.Query(qry => qry
.Text(text => text
.Field("field2")
.Query(field2TB.Text)
.Type(TextQueryType.phrase_prefix)
)
).Build();
I'm using YegoRoff's PlainElastic.Net from github. These two queries
work for me induvidually, but I now want to combine them - I tried,
string query1 = new QueryBuilder()
.Query(qry => qry
.Text(text => text
.Field("field1")
.Query(field1TB.Text)
.Type(TextQueryType.phrase_prefix)
.Field("field2")
.Query(field2TB.Text)
.Type(TextQueryType.phrase_prefix)
.Operator(Operator.AND) // could also be
operator.OR and would like to add multiple fields later on
)
).Build();
but this did not work for me. Also, I'm unable to figure out how to
use a must query, can I pass a text query in there instead of a term?
Thanks!

On May 15, 11:53 am, coys gautam...@gmail.com wrote:

On May 14, 7:15 am, Igor Motov imo...@gmail.com wrote:

Take a look at the Boolean
Queryhttp://
Elasticsearch Platform — Find real-time answers at scale | Elastic
You can use the "must" clause to "AND" queries and the "should" clause
to
"OR" them. If you still have a problem with formulating the query,
please
post an example of your query that doesn't work so we would understand
better what you have tried to do.

On Friday, May 11, 2012 7:49:21 PM UTC-4, coys wrote:

Hi, I have two different text queries(more specifically of type
phrase_prefix) and each of them individually return what I'm
expecting
but I can't figure out how to combine the two..more specifically AND
or OR them. I would also later want to perform this operation on
more
than 2 queries. Can you please give me an example of how I should do
this? Also, any links to tutorials on advanced text queries would be
very helpful! Thanks a lot!- Hide quoted text -

  • Show quoted text -- Hide quoted text -
  • Show quoted text -

Thanks a lot Igor for pointing me in the right direction! Just thought
I'd share the solution here,
query = new QueryBuilder()
.Query(q => q
.Bool(b => b
.Must(m => m
.Text(text => text
.Field("field1")
.Query(field1.Text)
.Type(TextQueryType.phrase_prefix)
)
.Text(text => text
.Field("field2")
.Query(field2.Text)
.Type(TextQueryType.phrase_prefix)
)
)
)).Build();
return query;

On May 15, 12:06 pm, Igor Motov imo...@gmail.com wrote:

Unfortunately, I don't have any experience with YegoRoff's
PlainElastic.Net, so I wouldn't be able to help you here. Have you seen how
Bool Queries are used in testshttps://github.com/Yegoroff/PlainElastic.Net/tree/master/src/PlainEla...
?

On Tuesday, May 15, 2012 1:54:43 PM UTC-4, coys wrote:

Hello, Thanks for the reply.
Basically, my two queries are :
string query1 = new QueryBuilder()
.Query(qry => qry
.Text(text => text
.Field("field1")
.Query(field1TB.Text)
.Type(TextQueryType.phrase_prefix)
)
).Build();
and string query2 = new QueryBuilder()
.Query(qry => qry
.Text(text => text
.Field("field2")
.Query(field2TB.Text)
.Type(TextQueryType.phrase_prefix)
)
).Build();
I'm using YegoRoff's PlainElastic.Net from github. These two queries
work for me induvidually, but I now want to combine them - I tried,
string query1 = new QueryBuilder()
.Query(qry => qry
.Text(text => text
.Field("field1")
.Query(field1TB.Text)
.Type(TextQueryType.phrase_prefix)
.Field("field2")
.Query(field2TB.Text)
.Type(TextQueryType.phrase_prefix)
.Operator(Operator.AND) // could also be
operator.OR and would like to add multiple fields later on
)
).Build();
but this did not work for me. Also, I'm unable to figure out how to
use a must query, can I pass a text query in there instead of a term?
Thanks!

On May 15, 11:53 am, coys gautam...@gmail.com wrote:

On May 14, 7:15 am, Igor Motov imo...@gmail.com wrote:

Take a look at the Boolean
Queryhttp://
Elasticsearch Platform — Find real-time answers at scale | Elastic
You can use the "must" clause to "AND" queries and the "should" clause
to
"OR" them. If you still have a problem with formulating the query,
please
post an example of your query that doesn't work so we would understand
better what you have tried to do.

On Friday, May 11, 2012 7:49:21 PM UTC-4, coys wrote:

Hi, I have two different text queries(more specifically of type
phrase_prefix) and each of them individually return what I'm
expecting
but I can't figure out how to combine the two..more specifically AND
or OR them. I would also later want to perform this operation on
more
than 2 queries. Can you please give me an example of how I should do
this? Also, any links to tutorials on advanced text queries would be
very helpful! Thanks a lot!- Hide quoted text -

  • Show quoted text -- Hide quoted text -
  • Show quoted text -- Hide quoted text -
  • Show quoted text -