Searching for URLs with dashes

Hi. I've such task that should be resolved.
All we know what is SEO and we know that all URLs of our websites should be
nice.
I've a website with products and URL of each product is something like
"apple-ipad", "apple-ipad-2".
When I'm trying to get product by URL with dash from ElasticSearch then it
works not in way I want.
This command gives me 4 products:
curl
"localhost:9200/shops/shops/_search?q=type:Product+AND+url.ru:apple-ipad-2"

But I know that there is only 1 product with URL "apple-ipad-2".
How can I get this 1 product?

--

You probably can wrap it with "

Better option could be to use a termQuery: http://www.elasticsearch.org/guide/reference/query-dsl/term-query.html

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 23 déc. 2012 à 16:52, Alexander Petrichkovich alexander.petrichkovich@gmail.com a écrit :

Hi. I've such task that should be resolved.
All we know what is SEO and we know that all URLs of our websites should be nice.
I've a website with products and URL of each product is something like "apple-ipad", "apple-ipad-2".
When I'm trying to get product by URL with dash from ElasticSearch then it works not in way I want.
This command gives me 4 products:
curl "localhost:9200/shops/shops/_search?q=type:Product+AND+url.ru:apple-ipad-2"

But I know that there is only 1 product with URL "apple-ipad-2".
How can I get this 1 product?

--

*curl
"localhost:9200/index/type/_count?q=type:Product+AND+url.ru:"apple-ipad-2""
*gives me 0 products.
*curl "localhost:9200/index/type/_count" -d "{"term":
{"url.ru": "apple-ipad-2"}}" *also gives me 0 products.

воскресенье, 23 декабря 2012 г., 18:44:43 UTC+2 пользователь David Pilato
написал:

You probably can wrap it with "

Better option could be to use a termQuery:
http://www.elasticsearch.org/guide/reference/query-dsl/term-query.html

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 23 déc. 2012 à 16:52, Alexander Petrichkovich <alexander.p...@gmail.com<javascript:>>
a écrit :

Hi. I've such task that should be resolved.
All we know what is SEO and we know that all URLs of our websites should
be nice.
I've a website with products and URL of each product is something like
"apple-ipad", "apple-ipad-2".
When I'm trying to get product by URL with dash from ElasticSearch then it
works not in way I want.
This command gives me 4 products:
*curl
"localhost:9200/shops/shops/_search?q=type:Product+AND+url.ru:apple-ipad-2"
*

But I know that there is only 1 product with URL "apple-ipad-2".
How can I get this 1 product?

--

--

It depends on your mapping.
If you analyzed your field with default mapping, your field has been broken in multiple terms:
Apple, iPad, 2

You have to define your mapping.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 23 déc. 2012 à 17:54, Alexander Petrichkovich alexander.petrichkovich@gmail.com a écrit :

curl "localhost:9200/index/type/_count?q=type:Product+AND+url.ru:"apple-ipad-2"" gives me 0 products.
curl "localhost:9200/index/type/_count" -d "{"term": {"url.ru": "apple-ipad-2"}}" also gives me 0 products.

воскресенье, 23 декабря 2012 г., 18:44:43 UTC+2 пользователь David Pilato написал:

You probably can wrap it with "

Better option could be to use a termQuery: http://www.elasticsearch.org/guide/reference/query-dsl/term-query.html

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 23 déc. 2012 à 16:52, Alexander Petrichkovich alexander.p...@gmail.com a écrit :

Hi. I've such task that should be resolved.
All we know what is SEO and we know that all URLs of our websites should be nice.
I've a website with products and URL of each product is something like "apple-ipad", "apple-ipad-2".
When I'm trying to get product by URL with dash from ElasticSearch then it works not in way I want.
This command gives me 4 products:
curl "localhost:9200/shops/shops/_search?q=type:Product+AND+url.ru:apple-ipad-2"

But I know that there is only 1 product with URL "apple-ipad-2".
How can I get this 1 product?

--

--