Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

"type": "keyword", is mentioned in Elastic search mapping but still giving the error of " fielddata=true"

As you can see below in the kibana mapping"type": "keyword", is already mentioned then why it is still giving me an error, while i run the seconnd code block?

StatusCodeError: [illegal_argument_exception] Fielddata is disabled on text fiel ds by default. Set fielddata=true on [time-stamp] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.<

{
  "web": {
    "aliases": {},
    "mappings": {
      "event": {
        "properties": {
            "participant-id": {
                        "type": "text",
                        "fields": {
                          "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                          }
                        }
                      },
                    }        
                  }
                },

I am trying to run this code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

          else if(req.query["participant-id"] !== undefined)
          {
            console.log('participant id');
            esClient.search({
            index:ESindex,

            body: {
              sort:[{"time-stamp":{"order":"desc"}}],
              size:req.query.count,
              query: {
                  match_phrase: { "participant-id":req.query["participant-id"] },

              }

              }
          },function (error, response,status) {
              if (error){
                console.log(error);
                return res.json({ message: 'error' });
              }
              else {
                  response.hits.hits.forEach(function(hit){
                   return resData.push(hit);
                })
              }
              return res.send(resData);

          });
          }

>Solution :

You are sorting on time-stamp field, and mapping which you shared doesn’t have this field, I am assuming this is defined as text field, and if your mapping is generated dynamically, you will have .keyword for time-stamp, Hence try using time-stamp.keyword in your sort clause.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading