Transitioning from `path` to `copy_to` with extracting field nested object


(Nemothekid) #1

Today I currently have a mapping like so:

conf = {
      "user": {
        "properties": {
          "id": {
            "type": "string",
            "index": "not_analyzed",
            "include_in_all": False
          },
          "created": {
            "type": "date",
            "include_in_all": False
          },
          "counts": {
            "type": "date",
            "path": "service.channel.stats.counts"
          }
}

It seems that with copy_to I would need to create all the objects up to counts in my mapping - or is there a simpler way?


(David Pilato) #2

No.

Or yes. On the client side?

IMO copy_to is the right thing to do.
I don't think it's difficult. You will replace one line path by one line copy_to.


(Nemothekid) #3

Right, during the creation of the mapping. The JSON I'm indexing is fixed at this point.

So there is no way other than create to nested objects for "service" then "channel", etc? To be clearer, my JSON object I'm going to index looks like this:

{
  "id":"aaa-bb-cc",
  "created":"yyyy-mm...",
  "service":{
     "other_fields":"...",
     "channel":{
         "other_fields":"...",
         "stats":{
             "counts":5,
             "other_fields":"...",
          }
      }
   }
}

And I want to be able to query ES (with query_string) like so:

created:{* TO 2012-01-01} counts:[0 to 100]

Path is what worked in this case before (IIRC), and I'm just wondering if this sort of use case has a new method. Thanks for your help.


(system) #4