Cannot find though the whole document


(Андрей Смолев) #1

Sorry if this is RTFM, but i spent several hours tried to compose
search query.

I have a clothes index with shirts, shoes and so on. All items have
some attributes such as collor, size, brand. In my application i have
search string like "red nike t-shirt" or just "red shirt". How can i
make elasticsearch to find relevant items?

Thanks!


(Gabriel Farrell) #2

You'll have to be more specific. Can you show us an example document?
Are you using explicit mappings? Are you using query_string in the
query DSL? In general, if you're adjusting relevancy, you'll want to

  1. adjust index-time boost with a mapping
    (http://www.elasticsearch.org/guide/reference/mapping/boost-field.html)
    and/or
  2. adjust query-time boost with a multi-field query_string
    (http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html)

On Thu, Oct 13, 2011 at 10:09 AM, Андрей andrey.smolev@gmail.com wrote:

Sorry if this is RTFM, but i spent several hours tried to compose
search query.

I have a clothes index with shirts, shoes and so on. All items have
some attributes such as collor, size, brand. In my application i have
search string like "red nike t-shirt" or just "red shirt". How can i
make elasticsearch to find relevant items?

Thanks!


(Андрей Смолев) #3

Resolved it this way
source={"query":{"query_string":{"default_field":"_all",
"default_operator":"AND","query":"white~0.7 shoes~0.7
adidas~0.7"}},"fields":["colorList","price","picture","name","vendor","shop","sizeList","colour_image","elegance","offer
id","description"],"size":100,"sort":{"_score":{"order":"desc"}},"filter":{"and":[{"term":{"available":1}}]}}

But I do not like "~0.7" in the querry, now I parse input string and replace
spaces with "~0.7 " but may be there is any better solution? tried "
fuzzy_min_sim":0.7 but it doesn't work like ~0.7...

On Fri, Oct 14, 2011 at 12:45 AM, Gabriel Farrell gsf747@gmail.com wrote:

You'll have to be more specific. Can you show us an example document?
Are you using explicit mappings? Are you using query_string in the
query DSL? In general, if you're adjusting relevancy, you'll want to

  1. adjust index-time boost with a mapping
    (http://www.elasticsearch.org/guide/reference/mapping/boost-field.html)
    and/or
  2. adjust query-time boost with a multi-field query_string
    (
    http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html
    )

On Thu, Oct 13, 2011 at 10:09 AM, Андрей andrey.smolev@gmail.com wrote:

Sorry if this is RTFM, but i spent several hours tried to compose
search query.

I have a clothes index with shirts, shoes and so on. All items have
some attributes such as collor, size, brand. In my application i have
search string like "red nike t-shirt" or just "red shirt". How can i
make elasticsearch to find relevant items?

Thanks!


(Gabriel Farrell) #4

fuzzy_min_sim only applies to terms with a tilde, but no required
similarity set. So you could change your query to "white~ shoes~
adidas~" and set fuzzy_min_sim to 0.7 for the same result.

Since you're already parsing the input, however, you might consider
putting all the terms in a fuzzy query (boosted at 0.8 or so) and
running it alongside the regular query.

On Fri, Oct 14, 2011 at 10:59 AM, Андрей Смолев andrey.smolev@gmail.com wrote:

Resolved it this way
source={"query":{"query_string":{"default_field":"_all",
"default_operator":"AND","query":"white~0.7 shoes~0.7
adidas~0.7"}},"fields":["colorList","price","picture","name","vendor","shop","sizeList","colour_image","elegance","offer
id","description"],"size":100,"sort":{"_score":{"order":"desc"}},"filter":{"and":[{"term":{"available":1}}]}}

But I do not like "~0.7" in the querry, now I parse input string and replace
spaces with "~0.7 " but may be there is any better solution? tried
"fuzzy_min_sim":0.7 but it doesn't work like ~0.7...

On Fri, Oct 14, 2011 at 12:45 AM, Gabriel Farrell gsf747@gmail.com wrote:

You'll have to be more specific. Can you show us an example document?
Are you using explicit mappings? Are you using query_string in the
query DSL? In general, if you're adjusting relevancy, you'll want to

  1. adjust index-time boost with a mapping
    (http://www.elasticsearch.org/guide/reference/mapping/boost-field.html)
    and/or
  2. adjust query-time boost with a multi-field query_string

(http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html)

On Thu, Oct 13, 2011 at 10:09 AM, Андрей andrey.smolev@gmail.com wrote:

Sorry if this is RTFM, but i spent several hours tried to compose
search query.

I have a clothes index with shirts, shoes and so on. All items have
some attributes such as collor, size, brand. In my application i have
search string like "red nike t-shirt" or just "red shirt". How can i
make elasticsearch to find relevant items?

Thanks!


(Андрей Смолев) #5

Thank you, it works for me!
On Oct 15, 2011 1:44 AM, "Gabriel Farrell" gsf747@gmail.com wrote:


(system) #6