Mapping Properties : Index : false


(Clément) #1

Hi everyone,
In my mapping properties, for one of the fields, I added "index : false" , but ElasticSearch is still indexing it and this field is still searchable. However, when I ask for the mapping, I do have:

"name" : {
"type" : "text",
"index" : false
},

Do I need to add something else to make it unindexed and unsearchable ?
Thank you,
Clement


(Igor Motov) #2

When I do this in v6.2

PUT test
{
  "mappings": {
    "doc": {
      "properties": {
        "name": {
          "type": "text",
          "index": false
        }
      }
    }
  }
}

PUT test/doc/1
{
  "name": "find me if you can"
}

POST test/doc/_search
{
  "query": {
    "match": {
      "name": "find"
    }
  }
}

I get an error message saying "Cannot search on field [name] since it is not indexed."

Which version are you using? Can you provide your mapping and the query?


(Clément) #3

Thank you for your fast reply!
I'm using Elasticsearch 6.2, and i forgot to mention that i'm also using Elasticquent.

My bad, I do have the same error when I query on this field. So this field is really unsearchable.

But is it normal that the field "name" and it's value still appear in the results among the other fields when I query : "http://localhost:9200/myIndex/_search?q=Mediolanum" for example ? Is it possible to completely remove so I can free some space on the future Elasticsearch server.


(Igor Motov) #4

Yes. By default the entire document is stored in the special field _source as it was passed to elasticsearch. It is done independently from indexing, so your mapping doesn't have any effect on how source is stored.

There are few ways to remove these fields from the source. The fastest way would be not to send these fields to elasticsearch in the first place. If your indexing layer is inflexible, you can remove such fields using ingest node. Or you can exclude fields from the source when the source is stored.


(Clément) #5

Thank very much! It's clear to me now


(system) #6

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