2013-04-06 59 views
0

长话短说。创建elastic.js查询

我需要创建elasticjs模拟查询:

http://example.com/one/two/_search?q=tags:three*

我很困惑与docs页面上列出的选项。已经尝试创建BoolQueryTermQuery和其他几个,但它们不适合我。

我现在卡住了,并会感谢任何形式的主题帮助。

P.S.而同一个问题的另一面。我无法找到json应该如何获取相同的数据。想出了这个解决方案,到目前为止,但遗憾的是它不工作:

{ 
    "query": { 
    "bool": { 
     "should": [ 
     { 
      "term": { 
      "tag": "three*" 
      } 
     } 
     ] 
    } 
    } 
} 

回答

1
ejs.Request() 
    .indices("one") 
    .types("two") 
    .query(ejs.QueryStringQuery ("tags:three*")) 
    .doSearch(function (data) { 
     // do something with data 
    }); 

附:在JSON:

{ 
    "query": { 
    "query_string": { 
     "query": "tags:three*" 
    } 
    } 
} 

{ 
    "query": { 
    "wildcard": { 
     "tags": "three*" 
    } 
    } 
}