Can't use text fields in lens : Kibana

Hello ,
I am a beginner for Elastic search.I have some difficulties dealing with lens in Kibana.

I imported a csv dataset named : 'traces_data' in Kibana .The main fields are : 'Code Op', 'Pays' ,' Marque' , 'Modèle' and 'Nom_traces' , which are text fields .However, 'Traduction Op' is a keyword field.

I have a problem in creating lens with the field 'TraductionOp' in kibana because it's a text field (non aggregatable) .That's why , i created a keyword field 'TraductionOp.raw ' by updating the mapping. At first the mapping was :

{
  "traces_data" : {
    "mappings" : {
      "_meta" : {
        "created_by" : "ml-file-data-visualizer"
      },
      "properties" : {
        "Code Op" : {
          "type" : "keyword"
        },
        "Marque" : {
          "type" : "keyword"
        },
        "Modéle" : {
          "type" : "keyword"
        },
        "Nom_traces" : {
          "type" : "keyword"
        },
        "Pays" : {
          "type" : "keyword"
        },
        "Traduction Op" : {
          "type" : "text"
        }
      }
    }
  }
}

I thought that creating a new keyword field for the text field 'Traduction Op' would help, so I updated the mapping :

{
  "traces_data" : {
    "mappings" : {
      "_meta" : {
        "created_by" : "ml-file-data-visualizer"
      },
      "properties" : {
        "Code Op" : {
          "type" : "keyword"
        },
        "Marque" : {
          "type" : "keyword"
        },
        "Modéle" : {
          "type" : "keyword"
        },
        "Nom_traces" : {
          "type" : "keyword"
        },
        "Pays" : {
          "type" : "keyword"
        },
        "Traduction Op" : {
          "type" : "text",
          "fields" : {
            "raw" : {
              "type" : "keyword"
            }
          }
        }
      }
    }
  }
} 

However , this solution could'nt resolve the problem . When I tried to use the new keyword field : TraductionOp.raw in lens , I had no results found.


I spent hours searching for an alternative to solve this problem . I would really appreciate your help .

Did you re-index your data? Editing the mapping and adding the keyword field will not fill it with data from your documents - I think this is why Lens isn't able to "see" it.

Check out the reindex API: Reindex API | Elasticsearch Guide [7.12] | Elastic

It will allow you to re-build the indices for you documents based on the mapping of the target index.

1 Like

I re-indexed the data and it worked ! Thanks @flash1293

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