Elastic mapping not working

I have one mapping which details are given below:

PUT my_index
{
  "mappings": {
    "product": {
      "properties": {
        "search_data": {
          "type": "nested",
          "properties":{
            "string_facet":{
              "type":"nested",
              "properties":{
                "facet_name":{
                  "type":"text"
                },
                "facet_value":{
                  "type":"text"
                }
              }
            }
          }
        }
      }
    }
  }
}

And I want to put my this below json array data to above mapping so that...it will comes under the search_data array...

PUT my_index/product/1
{
  "string_facet": [
        {
          "facet-name": "manufacturer",
          "facet-value": "Fortis"
        },
        {
          "facet-name": "hammer_weight",
          "facet-value": "1000"
        }
    ]
  
}

But after index...i got result like this...my json document is not going inside of the search_data...can anyone tell me where my mapping is wrong.

"hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "my_index",
        "_type": "product",
        "_id": "1",
        "_score": 1,
        "_source": {
          "string_facet": [
            {
              "facet-name": "manufacturer",
              "facet-value": "Fortis"
            },
            {
              "facet-name": "hammer_weight",
              "facet-value": "1000"
            }
          ]
        }
      }
    ]
  }
}

Thank you.

I got my error.....I corrected this problem....Thanks

Please share the solution so that future readers will know what the issue was.

Hi jpountz!..

My error was , I not created any search_data in the logstash but in mapping I am using that object name in mapping...so my mapping was not woking...but when i did my error correction in logstash like this..

mutate {
      rename => { "full_text" => "[search_data][full_text]" }
      rename => { "full_text_boosted" => "[search_data][full_text_boosted]" }
      rename => { "string_facet" => "[search_data][string_facet]" }
      }

Then its working...because now I am giving elasticsearch to command search_data to index...in which my other data are there...and when they reach to elasticsearch for index, it match with mapping....and I am getting result like this...as I want...

 "search_data" : {
            "full_text_boosted" : "179520 10000003368 sony handycam hxr mc1500p Electronics SONY",
            "completion_terms" : [
              "sony",
              "handycam",
              "hxr",
              "mc1500p"
            ],
            "scores" : {
              "cat_score" : 0.8999999761581421
            },
            "full_text" : "",
            "string_facet" : [
              {
                "facet-value" : "Electronics",
                "facet-name" : "category"
              }
}

Hope this will useful for you and other people..

Thanks

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