ES requires me to specify the type of data that I do not want to index

I want to save some data just in case (Suddenly, later come in handy).
I need them to not be indexed and not involved in the search.
If this data is later needed, I will get it from _source.
I tried to add mapping, but ES swears:

curl -s -H 'content-type: application/json; charset=UTF-8' "http://localhost:9205/test123/_mapping/searchtype?pretty" -XPUT  -d'{"properties" : {"name2":{"index":false}}}'
{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "No type specified for field [name2]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "No type specified for field [name2]"
  },
  "status" : 400
}

Why? This data is in the original JSON.
ES 6.8.

you need to specify the type of a field that you want to add. I suppose in this case it should be text or keyword.

--Alex

You did not understand.
I know that can specify the type and everything will work.
But I believe that this is not correct.
Suppose there is a flow of documents of the form:

{
  "name":"book3.pdf",
  "type":"book",
  "body":"......"
}
{
  "name":"rec9.pdf",
  "type":"recipе",
  "body":"......"
}
{
  "name":"crt7.pdf",
  "type":"certificate",
  "body":"......"
}

I analyze them through a pipeline script. For example:

"source":"if(ctx.type != 'book')ctx.notanalyzed=ctx.remove(body)"

I want to fully process only part of the documents. That is, all fields are indexed and searched by them. About the other part, I only need to know the name and type. Since there can be many documents, and the body can be large, I do not want unnecessary fields to be indexed at all. And I can’t remove the body field from them, because the client can come tomorrow and say: "We also need to find certificates!". In this case, I just correct the script and reindex the documents.

It is clear that in most cases it will be "text". But why should I specify a type for a field if I don't want to analyze and index it. There's some raw data. This data should only remain in _source and not be included in the index.

This data should only remain in _source and not be included in the index.

You should be able to achieve this by creating a text field mapping with 'index: false'

Naturally, I have two fields in mapping. "Body" to search and "noindexed" not to search.

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