JS - client.bulk() results in not mapped documents

Hey there!

I have a template with a mapping like this:

"template" : "database*",
"mappings": {
  	"_default_" : {
		"dynamic_templates" : [
			{
				// default string mapping
				"string" : {
					"match" : "*",
					"match_mapping_type": "string",
	                "mapping": {
	                    "type": "text",
				        "fields": {
				        	"raw" : {
				        		"type": "keyword"
				        	}
				        }
	                }
	            }
	        },
		]
	}
}

The idea behind this template is to generate for every new field a "type : keyword" field for exact searches.

When adding documents (in an empty index using this template) with JS API client.index() everything works fine, this way i am able to query like:

{
    "query": {
        "match": {
          "fooBar": "bla" 
        }
    }
}

Or for exact searches like:

{
    "query": {
        "match": {
          "fooBar.raw": "bla" 
        }
    }
}

But adding documents (again empty index) in bulk with client.bulk(), the same "raw" request results in an error:

"No mapping found for [fooBar.raw] (...)"

while:

{
    "query": {
        "match": {
          "fooBar": "bla" 
        }
    }
}

delivers results. This brings me to the conclusion, that the document is indeed indexed but the field "raw" has not been created.

Is that right? Is in fact bulk Indexing not using mapping?

How can I use bulk import and map the documents?

Thanks! :slight_smile:

Does the indices you bulk index into match the pattern specified in the index template? Can you show a sample document?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.