Disable norms for all fields


(Yadu) #1

My application doesn't need any kind of boost/score, we do plain boolean
search. So I tried to disable norms at index time using dynamic template
like

"dynamic_templates" : [
..................................
....................................
,{
"template_apply_to_all_es_fields" : {
"match" : "*",
"mapping" : {
"type": "{dynamic_type}",
"omit_norms" : true,
"index_options" : "docs"
}
}
}
]

when I tried to save document it throws error:

{
   "error": "MapperParsingException[failed to find type parsed [{dynamic_type}] for [person]]",
   "status": 400
}

where 'person' is type of document and also the root node in the document.

Is "type": "{dynamic_type}" is not a correct usage in this case?
Is there any other way to disable norms for all fields including fields of
nested objects?

I know we can disable norms by putting "omit_norms" : true, "index_options"
: "docs" on every field mapping.

Thanks for your help!

-Yadu

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Yadu) #2

I ignored the fact that omit_norms and index_options are only for string
type. So I added mapping given below for string fields identified
dynamically. Each statically mapped string field requires omit_norms and
index_options explicitly in its mapping.

{
"template_strings_no_norms" : {
"mapping" : {
"type" : "string",
"omit_norms" : true,
"index_options" : "docs"
},
"match" : "*",
"match_mapping_type" : "string"
}
}

Mappings are as expected now and working fine. But it seems score is still
getting calculated which is weird.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Dominik Stadler) #3

There was a similar discussion at How to disable "Norms" for all field? and the issue at https://github.com/elastic/elasticsearch/issues/19716 discusses this and there seems to be a working example provided there.


(system) #4