# Searching for whole URL using elastic4s

**URL:** <https://discuss.elastic.co/t/searching-for-whole-url-using-elastic4s/29683>\
**Category:** Elasticsearch\
**Created:** [September 21, 2015, 9:00am UTC](https://discuss.elastic.co/t/searching-for-whole-url-using-elastic4s/29683 "2015-09-21T09:00:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anatolyr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anatolyr/32/4876_2.png) [@anatolyr](https://discuss.elastic.co/u/anatolyr)\
**Post date:** [September 21, 2015, 9:00am UTC](https://discuss.elastic.co/t/searching-for-whole-url-using-elastic4s/29683/1 "2015-09-21T09:00:14Z")

</div>

I'm using elastic4s in order to index and search data in ES. Part of the document I'm storing contains a url field which I need to search for (the entire url). The problem occurs when I search for a document containing the url field and get 0 results.

For the purpose of this search I define a mapping ahead of inserting the data into the index:

```
client.execute {
  create index <my_index> mappings {
    <my_type> as {
      "url" typed StringType analyzer NotAnalyzed
    }
  }
}

```

I'm inserting the data:

```
client.execute { index into <my_index> -> <my_type> fields (
  "url" -> "http://sample.com"
  )
}.await

```

And I search for the documents:

```
val filter =
"""
  |{
  | "filtered" : {
  | "query" : {
  | "match_all" : {}
  | },
  | "filter" : {
  | "bool" : {
  | "should" : [
  | { "bool" : {
  | "must" : [
  | { "term" : { "url" : "http://sample.com" } }
  | ]
  | } }
  | ]
  | }
  | }
  | }
  |}
""".stripMargin

client.execute { search in <my_index> -> <my_type> rawQuery { filter } }.await

```

I get 0 results after executing this query. What am I doing wrong?

Thanks!

P.S.  
I'v also posted this question here: [https://stackoverflow.com/questions/32690966/searching-for-whole-url-using-elastic4s](https://stackoverflow.com/questions/32690966/searching-for-whole-url-using-elastic4s)

---

<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 5, 2017, 11:49pm UTC](https://discuss.elastic.co/t/searching-for-whole-url-using-elastic4s/29683/2 "2017-07-05T23:49:06Z")

</div>


