2016-05-12 38 views

回答

0

我有同样的问题。请执行以下操作以使其正常工作。

确保您删除索引:

通过邮递员例如DELETE请求:http://127.0.0.1:9200/ {your_name}

然后在节点JS创建这样的映射:

var schema = new Schema({ 
    product_name: String, 
    description: { 
     type: String, 
     es_type: 'multi_field', 
     es_fields: { 
      multi_field: { type: 'string', index: 'analyzed' }, 
      untouched: { type: 'string', index: 'not_analyzed' } 
     } 
    } 
}); 

最后,你可以像这样的查询:

{ 
"query" : { 
    "constant_score" : { 
     "filter" : { 
      "term" : { 
       "description.multi_field" : "nog een testje" 
      } 
     } 
    } 
}}// to use other field, change the . after description 
{ 
"query" : { 
    "constant_score" : { 
     "filter" : { 
      "term" : { 
       "description.untouched" : "nog een testje" 
      } 
     } 
    } 
} 

}