In Elasticsearch, I want to query terms and also get results from URLs. Therefore I've tried to let the field "url" be analyzed and queried the following way - but the result was always empty.
index-config.json:
{
  "mappings": {
    "Mytype": {
      "properties": {
        "about": {
          "url": {
            "type": "string",
            "analyzer":"url_analyzer"
  }}}}},
  "settings" : {
    "analysis": {
      "analyzer": {
        "url_analyzer": {
          "type": "custom",
          "tokenizer": "url_tokenizer"
        }
      },
      "tokenizer": {
        "url_tokenizer" : {
          "type": "pattern",
          "pattern": "[\\.:/]+"
}}}}}
Query in head-plugin:
{
  "query": {
    "bool": {
      "must": [{
          "query_string": {
            "default_field": "Mytype.url",
            "query": "myquery"
      }}],
      "must_not": [],
      "should": []
  }},
  "from": 0,
  "size": 10,
  "sort": [],
  "facets": {}
}
(I've queried a bit differently through the Java API as well - same problem occuring.)
Result:
Now, that works if I take e.g. stackoverflow.com as myquery.
But the result is empty, if I take stackoverflow only.
That confuses me, because I think the pattern of the url_tokenizer should take the . as a limiter.
What is wrong here?
aboutis an object field, then you must include theurlsub-field inside apropertiesstructure. Can you extract the actual mapping usingcurl -XGET localhost:9200/your_indexand update your question with it?org.elasticsearch.ElasticsearchIllegalArgumentException: failed to find token filter type [url] for [url_host]. ==> Maybe a new question?