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