# Searching for URLs with dashes

**URL:** <https://discuss.elastic.co/t/searching-for-urls-with-dashes/10161>\
**Category:** Elasticsearch\
**Created:** [December 23, 2012, 3:52pm UTC](https://discuss.elastic.co/t/searching-for-urls-with-dashes/10161 "2012-12-23T15:52:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Petrichkov](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Alexander\_Petrichkov](https://discuss.elastic.co/u/Alexander_Petrichkov)\
**Post date:** [December 23, 2012, 3:52pm UTC](https://discuss.elastic.co/t/searching-for-urls-with-dashes/10161/1 "2012-12-23T15:52:17Z")

</div>

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](http://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?

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 23, 2012, 4:44pm UTC](https://discuss.elastic.co/t/searching-for-urls-with-dashes/10161/2 "2012-12-23T16:44:43Z")

</div>

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](http://www.elasticsearch.org/guide/reference/query-dsl/term-query.html)

## HTH

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

Le 23 déc. 2012 à 16:52, Alexander Petrichkovich [alexander.petrichkovich@gmail.com](mailto: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?

--

---

<div class="post-metadata">

**Author:** ![Alexander\_Petrichkov](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Alexander\_Petrichkov](https://discuss.elastic.co/u/Alexander_Petrichkov)\
**Post date:** [December 23, 2012, 4:54pm UTC](https://discuss.elastic.co/t/searching-for-urls-with-dashes/10161/3 "2012-12-23T16:54:58Z")

</div>

\*curl  
"localhost:9200/index/type/\_count?q=type:Product+[AND+url.ru](http://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:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/term-query.html)
> 
> ## HTH
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 23 déc. 2012 à 16:52, Alexander Petrichkovich \<[alexander.p...@gmail.com](mailto: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](http://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?
> 
> --

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 23, 2012, 4:57pm UTC](https://discuss.elastic.co/t/searching-for-urls-with-dashes/10161/4 "2012-12-23T16:57:44Z")

</div>

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 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

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

curl "localhost:9200/index/type/\_count?q=type:Product+[AND+url.ru](http://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: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/term-query.html)
> 
> ## HTH
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 23 déc. 2012 à 16:52, Alexander Petrichkovich [alexander.p...@gmail.com](mailto: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](http://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?

--

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:58am UTC](https://discuss.elastic.co/t/searching-for-urls-with-dashes/10161/5 "2017-07-06T02:58:39Z")

</div>


