ElasticSearch - A dot in the field name of a nested object

I have data of this form:

{
  "workers": {
    "worker.1": {
      "jobs": 1234
    }, 
  }, 
  "total_jobs": 1234
}

and I'm trying to deal with the presence of a "dot" in the field name. I tried this mapping:

{
  "worker_stats": {
    "properties": {
      "workers": {
        "type": "object", 
        "properties": {
          "worker.1": {
            "type": "nested", 
            "index_name": "worker_1", 
            "properties": {
              "jobs": {
                "type": "integer"
              }
            }
          }
        }
      }, 
      "total_jobs": {
        "type": "integer"
      }
    }
  }
}

but when I get my mapping, index_name should not be visible, and when I add the document, it still gets the point.

Ultimately, I'm just trying to make some clusters:

{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      }
    }
  }, 
  "aggs": {
    "worker1_stats": {
      "aggs": {
        "stats": {
          "stats": {
            "field": "workers.worker.1.jobs"
          }
        }
      }, 
      "nested": {
        "path": "workers.worker.1"
      }
    }
  }
}

but the point is in the way.

What can I do to deal with this point? Is there any way to use scriptinstead field? (Is my use nestedcorrect?

+3
source share
1 answer

, index_name, path type : object , .

:

PUT /twitter/
{
    "settings" : {
        "number_of_shards" : 5,
        "number_of_replicas" : 0
    },
    "mappings": {
        "tweet":{
            "properties": {
                "desc.youbet":{"type":"object","path":"just_name",
                "properties": {
                    "one": {
                    "type": "integer", "index_name":"one"
                    }
                }
                }
            }
        }
    }
}

PUT /twitter/tweet/1 
{
    "name":"chicken",
    "desc.youbet":{
        "one":1,
    }
}

PUT /twitter/tweet/2 
{
    "name":"chicken",
    "desc.youbet":{
        "one":1,
    }
}

desc , , :

POST /twitter/tweet/_search
{
    "query": {"match_all": {}},
    "aggs":{
        "stats": {
          "stats": {"field": "one"}
        }
    }, "size":0
}

:

{
   "took": 2,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 2,
      "max_score": 0,
      "hits": []
   },
   "aggregations": {
      "stats": {
         "count": 2,
         "min": 1,
         "max": 1,
         "avg": 1,
         "sum": 2
      }
   }
}
0

All Articles