2017-07-18 1 views
1

Ich bin der diese Abfrage ausführen:Erste Ungültige Anzahl Ausnahme auf elastische Suchabfrage

{ 
    "query" : { 
    "match" : { 
     "studyID" : { 
     "query" : 1, 
     "type" : "boolean" 
     } 
    } 
    }, 
    "aggregations" : { 
    "25-34" : { 
     "date_range" : { 
     "field" : "timestamp", 
     "ranges" : [ { 
      "from" : "1992", 
      "to" : "1983" 
     } ], 
     "format" : "yyyy" 
     }, 
     "aggregations" : { 
     "activityType" : { 
      "terms" : { 
      "field" : "activityType" 
      } 
     } 
     } 
    }, 
    "84-*" : { 
     "date_range" : { 
     "field" : "timestamp", 
     "ranges" : [ { 
      "from" : "1933" 
     } ], 
     "format" : "yyyy" 
     }, 
     "aggregations" : { 
     "activityType" : { 
      "terms" : { 
      "field" : "activityType" 
      } 
     } 
     } 
    }, 
    "18-24" : { 
     "date_range" : { 
     "field" : "timestamp", 
     "ranges" : [ { 
      "from" : "1999", 
      "to" : "1993" 
     } ], 
     "format" : "yyyy" 
     }, 
     "aggregations" : { 
     "activityType" : { 
      "terms" : { 
      "field" : "activityType" 
      } 
     } 
     } 
    }, 
    "75-84" : { 
     "date_range" : { 
     "field" : "timestamp", 
     "ranges" : [ { 
      "from" : "1942", 
      "to" : "1933" 
     } ], 
     "format" : "yyyy" 
     }, 
     "aggregations" : { 
     "activityType" : { 
      "terms" : { 
      "field" : "activityType" 
      } 
     } 
     } 
    }, 
    "0-17" : { 
     "date_range" : { 
     "field" : "timestamp", 
     "ranges" : [ { 
      "from" : "2017", 
      "to" : "2000" 
     } ], 
     "format" : "yyyy" 
     }, 
     "aggregations" : { 
     "activityType" : { 
      "terms" : { 
      "field" : "activityType" 
      } 
     } 
     } 
    }, 
    "55-64" : { 
     "date_range" : { 
     "field" : "timestamp", 
     "ranges" : [ { 
      "from" : "1962", 
      "to" : "1953" 
     } ], 
     "format" : "yyyy" 
     }, 
     "aggregations" : { 
     "activityType" : { 
      "terms" : { 
      "field" : "activityType" 
      } 
     } 
     } 
    }, 
    "65-74" : { 
     "date_range" : { 
     "field" : "timestamp", 
     "ranges" : [ { 
      "from" : "1952", 
      "to" : "1943" 
     } ], 
     "format" : "yyyy" 
     }, 
     "aggregations" : { 
     "activityType" : { 
      "terms" : { 
      "field" : "activityType" 
      } 
     } 
     } 
    }, 
    "35-44" : { 
     "date_range" : { 
     "field" : "timestamp", 
     "ranges" : [ { 
      "from" : "1982", 
      "to" : "1973" 
     } ], 
     "format" : "yyyy" 
     }, 
     "aggregations" : { 
     "activityType" : { 
      "terms" : { 
      "field" : "activityType" 
      } 
     } 
     } 
    }, 
    "45-54" : { 
     "date_range" : { 
     "field" : "timestamp", 
     "ranges" : [ { 
      "from" : "1972", 
      "to" : "1963" 
     } ], 
     "format" : "yyyy" 
     }, 
     "aggregations" : { 
     "activityType" : { 
      "terms" : { 
      "field" : "activityType" 
      } 
     } 
     } 
    } 
    } 
} 

Wo ich will nur Aktivität zur Aggregation basierend auf Datumsbereiche und dann aggregieren Unter diesen Bereiche durch Leistungsart aber Elastic Suche ist mir geben diese ausnahme:

{ 
    "error": { 
     "root_cause": [ 
      { 
       "type": "aggregation_execution_exception", 
       "reason": "Invalid number format [yyyy#]" 
      } 
     ], 
     "type": "search_phase_execution_exception", 
     "reason": "all shards failed", 
     "phase": "query", 
     "grouped": true, 
     "failed_shards": [ 
      { 
       "shard": 0, 
       "index": "study", 
       "node": "MWkXAAOCSYuM-ubdkulNnw", 
       "reason": { 
        "type": "aggregation_execution_exception", 
        "reason": "Invalid number format [yyyy#]" 
       } 
      } 
     ] 
    }, 
    "status": 500 
} 

Irgendwelche Ideen was vermisse ich?

Antwort

0

Der Parameter format gibt an, in welchem ​​Format die Daten in der Antwort zurückgegeben werden sollen und nicht in welchem ​​Format sie in der Anforderung angegeben sind. Also je nach Datumsformat des timestamp Feld, das Sie in Ihrem Mapping-Typ angegeben haben, muss Ihre Anfrage Voll fledge Daten enthalten, wie folgt aus:

"25-34" : { 
    "date_range" : { 
    "field" : "timestamp", 
    "ranges" : [ { 
     "from" : "1992-01-01T00:00:00.000Z", 
     "to" : "1983-12-31T23:59.59.999Z" 
    } ], 
    "format" : "yyyy" 
    }, 
    "aggregations" : { 
    "activityType" : { 
     "terms" : { 
     "field" : "activityType" 
     } 
    } 
    } 
}, 
+0

irgendein Glück mit diesem? – Val