2013-04-06 57 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*" 
    } 
    } 
}