termQuery behavior with multiple words


(Frank LaRosa) #1

Suppose my user types in a search string with multiple words, like
"yellow car".

I want to find all documents that have both words, not necessarily
adjacent or in the same order, but not documents that contain only one
of the words.

If I used something like termQuery("description", "yellow car"), what
would this produce?

Do I need to parse the individual words out of the search string
myself to accomplish what I want?


(plaflamme) #2

You're probably looking for this:

http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html
or this, to breakdown your query string before searching
http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze.html

If you're not familiar with Lucene, you may want to read about analyzers.
They're the things that breakdown full text into indexable/searchable
pieces.

Hope it helps,
Philippe

On Tue, Jan 10, 2012 at 15:36, Frank LaRosa frank@studyblue.com wrote:

Suppose my user types in a search string with multiple words, like
"yellow car".

I want to find all documents that have both words, not necessarily
adjacent or in the same order, but not documents that contain only one
of the words.

If I used something like termQuery("description", "yellow car"), what
would this produce?

Do I need to parse the individual words out of the search string
myself to accomplish what I want?


(Frank LaRosa) #3

I'm familiar with Solr. Can I just submit a Solr query string?

For example, when I'm using Solr I might submit a query such as
"+description:yellow +description:car".

On Jan 10, 3:31 pm, Philippe Laflamme philippe.lafla...@obiba.org
wrote:

You're probably looking for this:

http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html
or this, to breakdown your query string before searchinghttp://www.elasticsearch.org/guide/reference/api/admin-indices-analyz...

If you're not familiar with Lucene, you may want to read about analyzers.
They're the things that breakdown full text into indexable/searchable
pieces.

Hope it helps,
Philippe

On Tue, Jan 10, 2012 at 15:36, Frank LaRosa fr...@studyblue.com wrote:

Suppose my user types in a search string with multiple words, like
"yellow car".

I want to find all documents that have both words, not necessarily
adjacent or in the same order, but not documents that contain only one
of the words.

If I used something like termQuery("description", "yellow car"), what
would this produce?

Do I need to parse the individual words out of the search string
myself to accomplish what I want?


(Frank LaRosa) #4

This is nice, but it's not Java. Isn't there a Java API for any of
this stuff?

On Jan 10, 3:31 pm, Philippe Laflamme philippe.lafla...@obiba.org
wrote:

You're probably looking for this:

http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html
or this, to breakdown your query string before searchinghttp://www.elasticsearch.org/guide/reference/api/admin-indices-analyz...

If you're not familiar with Lucene, you may want to read about analyzers.
They're the things that breakdown full text into indexable/searchable
pieces.

Hope it helps,
Philippe

On Tue, Jan 10, 2012 at 15:36, Frank LaRosa fr...@studyblue.com wrote:

Suppose my user types in a search string with multiple words, like
"yellow car".

I want to find all documents that have both words, not necessarily
adjacent or in the same order, but not documents that contain only one
of the words.

If I used something like termQuery("description", "yellow car"), what
would this produce?

Do I need to parse the individual words out of the search string
myself to accomplish what I want?


(plaflamme) #5

Yes, using this:
http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html

On Tue, Jan 10, 2012 at 16:36, Frank LaRosa frank@studyblue.com wrote:

I'm familiar with Solr. Can I just submit a Solr query string?

For example, when I'm using Solr I might submit a query such as
"+description:yellow +description:car".

On Jan 10, 3:31 pm, Philippe Laflamme philippe.lafla...@obiba.org
wrote:

You're probably looking for this:

http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html
or this, to breakdown your query string before searchinghttp://
www.elasticsearch.org/guide/reference/api/admin-indices-analyz...

If you're not familiar with Lucene, you may want to read about analyzers.
They're the things that breakdown full text into indexable/searchable
pieces.

Hope it helps,
Philippe

On Tue, Jan 10, 2012 at 15:36, Frank LaRosa fr...@studyblue.com wrote:

Suppose my user types in a search string with multiple words, like
"yellow car".

I want to find all documents that have both words, not necessarily
adjacent or in the same order, but not documents that contain only one
of the words.

If I used something like termQuery("description", "yellow car"), what
would this produce?

Do I need to parse the individual words out of the search string
myself to accomplish what I want?


(plaflamme) #6

Yes, there is. Look for SearchSourceBuilder to build search queries.

Philippe

On Tue, Jan 10, 2012 at 16:44, Frank LaRosa frank@studyblue.com wrote:

This is nice, but it's not Java. Isn't there a Java API for any of
this stuff?

On Jan 10, 3:31 pm, Philippe Laflamme philippe.lafla...@obiba.org
wrote:

You're probably looking for this:

http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html
or this, to breakdown your query string before searchinghttp://
www.elasticsearch.org/guide/reference/api/admin-indices-analyz...

If you're not familiar with Lucene, you may want to read about analyzers.
They're the things that breakdown full text into indexable/searchable
pieces.

Hope it helps,
Philippe

On Tue, Jan 10, 2012 at 15:36, Frank LaRosa fr...@studyblue.com wrote:

Suppose my user types in a search string with multiple words, like
"yellow car".

I want to find all documents that have both words, not necessarily
adjacent or in the same order, but not documents that contain only one
of the words.

If I used something like termQuery("description", "yellow car"), what
would this produce?

Do I need to parse the individual words out of the search string
myself to accomplish what I want?


(Karussell) #7

Have a look:

http://www.elasticsearch.org/guide/reference/java-api/query-dsl.html

then pass this to the TransportClient

http://www.elasticsearch.org/guide/reference/java-api/client.html

Peter.

On 11 Jan., 02:25, Philippe Laflamme philippe.lafla...@obiba.org
wrote:

Yes, there is. Look for SearchSourceBuilder to build search queries.

Philippe

On Tue, Jan 10, 2012 at 16:44, Frank LaRosa fr...@studyblue.com wrote:

This is nice, but it's not Java. Isn't there a Java API for any of
this stuff?

On Jan 10, 3:31 pm, Philippe Laflamme philippe.lafla...@obiba.org
wrote:

You're probably looking for this:

http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html
or this, to breakdown your query string before searchinghttp://
www.elasticsearch.org/guide/reference/api/admin-indices-analyz...

If you're not familiar with Lucene, you may want to read about analyzers.
They're the things that breakdown full text into indexable/searchable
pieces.

Hope it helps,
Philippe

On Tue, Jan 10, 2012 at 15:36, Frank LaRosa fr...@studyblue.com wrote:

Suppose my user types in a search string with multiple words, like
"yellow car".

I want to find all documents that have both words, not necessarily
adjacent or in the same order, but not documents that contain only one
of the words.

If I used something like termQuery("description", "yellow car"), what
would this produce?

Do I need to parse the individual words out of the search string
myself to accomplish what I want?


(system) #8