Term Filtered query doesn't work for field with index: not_analyzed

(Marek K) #1


I have a problem with query. I want to find document by one of the field using term filtered query (I need to find exact match).

I've got index definition:

	"settings": {
		"analysis": {
			"default": {
				"tokenizer": "standard",
				"filter": ["standard", "lowercase", "asciifolding"]
			"char_filter": {
				"&_to_and": {
					"type": "mapping",
					"mappings": ["&=> and "]
			"analyzer": {
				"page_analyzer": {
					"type": "custom",
					"char_filter": ["&_to_and"],
					"filter": ["standard", "lowercase", "asciifolding"],
					"tokenizer": "standard"
	"mappings": {
		"assets": {
			"_id": {
				"path": "assetId"
			"properties": {
				"assetId": {
					"type": "string",
					"include_in_all": false,
					"index": "not_analyzed"
				"path": {
					"type": "string",
					"index": "not_analyzed",
					"include_in_all": false

And I try to find a document which has path "/assets/path with spaces.jpg".
I execute following query:

{"filtered" : {"query" : {"match_all" : { }},"filter" : {"term" : {"path" : "/assets/path with spaces.jpg"}}}}

But I don't get any results. I checked mappings for my index and they are correct. What I'm doing wrong? I will add that if I will change that query to mathQueryPrefix then I get my result, but there is a chance that i will get too many results.

(Doug Turnbull) #2

Nothing is jumping out at me, seems like this should work. Your mappings shouldn't matter, you're doing a filter on an unanalyzed field. Can you share a sample document? It could be something silly like a trailing space or capitalization. Remember these have to be EXACTLY the same, including case and random bits of whitespace

(Doug Turnbull) #3

To clarify your analyzers shouldn't matter, your mappings matter quite a
bit :slight_smile:

(system) #4