2015-11-19 30 views
7

Cercando di creare classificazione, sotto elasticsearch 2 con il seguente comando, ma non riesce:elasticsearch mappatura non lavora

POST /my_blog  
{ 
    "settings": { 
     "index" : { 
      "number_of_shards" : 10 
     } 
    },  
    "mappings": { 
     "post" : {   
      "_routing" : { 
       "required": false, 
       "path" : "post_date" 
      }, 
      "properties": { 
       "user_id" :{ 
        "type": "integer"      
       }, 
       "post_text" : { 
        "type": "string"      
       }, 
       "post_date": { 
        "type" : "date", 
        "format" : "YYYY-MM-DD" 
       } 
      } 
     } 
    } 
} 

Risposta:

{ 
    "error": { 
     "root_cause": [ 
     { 
      "type": "mapper_parsing_exception", 
      "reason": "Mapping definition for [_routing] has unsupported parameters: [path : post_date]" 
     } 
     ], 
     "type": "mapper_parsing_exception", 
     "reason": "mapping [post]", 
     "caused_by": { 
     "type": "mapper_parsing_exception", 
     "reason": "Mapping definition for [_routing] has unsupported parameters: [path : post_date]" 
     } 
    }, 
    "status": 400 
} 

Non importa quale campo ho scelto per la percorso, numero intero/stringa o data, dà sempre la stessa risposta di errore (vedi sopra). Qualche idea?

risposta

6

Dai uno sguardo allo type meta-field changes in 2.0. Quello che stai cercando di fare non può più essere fatto.

Dovrete creare l'indice in questo modo:

POST /my_blog  
{ 
    "settings": { 
     "index" : { 
      "number_of_shards" : 10 
     } 
    },  
    "mappings": { 
     "post" : {   
      "_routing" : { 
       "required": false 
      }, 
      "properties": { 
       "user_id" :{ 
        "type": "integer"      
       }, 
       "post_text" : { 
        "type": "string"      
       }, 
       "post_date": { 
        "type" : "date", 
        "format" : "YYYY-MM-DD" 
       } 
      } 
     } 
    } 
} 

quindi specificare il percorso nella stringa di query di ogni documento indicizzato, come:

PUT /my_blog/post/1?routing=2015-11-19 
{ 
    "user_id": 1, 
    "post_text": "Lorem ipsum", 
    "post_date": "2015-11-19" 
} 
+0

Grazie, mi prendo un Guarda. –

+0

E in realtà se si intende contrassegnare il 'routing' come non richiesto, si può anche lasciare la clausola, per quanto posso dire. –

Problemi correlati