Elasticsearch - how to search an URL?

Question

I have a problem when I store data like this into Elasticsearch (v 2.3, in AWS):

{
  data: {
    url: 'https://www.mydomain.tld',
    someOtherField: 'value',
  }
}

index mapping:

{
  "mappings": {
    "nodes": {
      "properties": {
        "data": {
          "properties": {
            "url": {
              "type": "string",
              "index": "not_analyzed"
            }
           }
         }
       }
     }
   }
}

I didn't find anyway, how can I search queries like:

http:, https:, http://, https://, and so on...

Long story short I need to search URLs, with protocol - an exact partial match. Because at least colon is a special mark, searching does not return relevant results, even is field not analysed.

Can anyone help me, please?


Show source
| url   | search   | elasticsearch   2016-11-25 15:11 1 Answers

Answers to Elasticsearch - how to search an URL? ( 1 )

  1. 2016-11-29 11:11

    For me best worked wildcard like this at this time. Even if I know it is slow solution, it is the only suitable:

    {
      query: {
        "wildcard" : { "data.url" : "https://foo*" }
      }
    }
    

    The prerequisity is to have field not analyzed.

Leave a reply to - Elasticsearch - how to search an URL?

◀ Go back