0
{
  "_source": {
    "enabled": false
  },
  "analysis": {
    "analyzer": {
      "default": {
        "type": "custom",
        "tokenizer": "uax_url_email",
        "filter": "lowercase,standard,stop"
      }
    }
  },
  "mappings": {
    "table": {
      "properties": {
        "field1": {
          "type": "string",
          "include_in_all": false,
          "index": "no"
        },
        "field2": {
          "type": "long",
          "include_in_all": false,
          "index": "no"
        },
        "field3": {
              "type": "string",
              "index": "analyzed"
            }
      }
    }
  }
}

The analyzer doesn't seem to work when testing it. The analyzer should not index stop words and it should also index an email address as a whole. When I "TEST ANALYZER" and type "Jack is fine", indexing of all three words takes place. I do not want it to index the stopwords in english language such as "and","is" etc.

Akshat
  • 11
  • 1
  • 5

1 Answers1

1

You set the fields to be "index": "no" and also disable include_in_all. How do you expect to have something put in the index? Quote from the documentation:

no means that it won’t be searchable at all (as an individual field; it may still be included in _all). Setting to no disables include_in_all.

And the actual settings should be like this (you are missing "settings" from your index definition):

{
  "_source": {
    "enabled": false
  },
  "settings": {
    "analysis": {
      "analyzer": {
        "default": {
          "type": "custom",
          "tokenizer": "uax_url_email",
          "filter": "lowercase,standard,stop"
        }
      }
    }
  },
  "mappings": {
    "table": {
      "properties": {
        "field1": {
          "type": "string",
          "include_in_all": false,
          "index": "no"
        },
        "field2": {
          "type": "long",
          "include_in_all": false,
          "index": "no"
        },
        "field3": {
          "type": "string",
          "index": "analyzed"
        }
      }
    }
  }
}
Andrei Stefan
  • 51,654
  • 6
  • 98
  • 89
  • I do have other fields in which the index is set to 'yes', just that I haven't shown those in this particular code snippet. I can show those if you want. – Akshat Jun 08 '15 at 09:21
  • Share more than that, because the question is not completely clear. Share what have you tried (exact commands), what was the result and what was the expectation. – Andrei Stefan Jun 08 '15 at 09:25
  • I am new to stackoverflow, so I didn't know how much to explain. I have explained the problem further. – Akshat Jun 08 '15 at 09:37
  • I have edited my answer. You are missing a key element in your index definition: the `settings`. Try my code and see if it works for you. – Andrei Stefan Jun 08 '15 at 09:38