2016-08-02 44 views
0

我想創建具有文檔作爲下Solr的創建核心已經JSON對象和JSON的數組對象類似於彈性搜索

{ 
    "dataSet_s": "MYSQL_NEW_W", 
    "ruleType_s": "IF_EQUALS_THEN_EQUALS", 
    "enable_s": "true", 
    "testCaseId_s": "CASE_2", 
    "condition": { 
    "conClause_s": "IF", 
    "conField_s": "ENGINE_RPM", 
    "conOperator1_s": "GREATER", 
    "conVal1_s": "5000", 
    "conVal2_s": "1000" 
    }, 
    "result": [ 
    { 
     "resClause1": "THEN", 
     "resField1": "SPEED", 
     "resOperator1": "EQUALS", 
     "resVal1": "100", 
     "resVal2": "200" 
    }, 
    { 
     "resClause1": "THEN", 
     "resField1": "SPEED", 
     "resOperator1": "GREATER", 
     "resVal1": "1000", 
     "resVal2": "2000" 
    } 
    ] 
}' 

在彈性搜索核心文檔具有插入之後的相同的結構,但Solr中,當我試圖插入創建一個簡單的核心,它看起來以後。

{ 
     "dataSet_s": "MYSQL_NEW_W", 
     "ruleType_s": "IF_EQUALS_THEN_EQUALS", 
     "enable_s": "true", 
     "testCaseId_s": "CASE_2", 
     "condition.conClause_s": "IF", 
     "condition.conField_s": "ENGINE_RPM", 
     "condition.conOperator1_s": "GREATER", 
     "condition.conVal1_s": "5000", 
     "condition.conVal2_s": "1000", 
     "result.resClause1": [ 
      "THEN", 
      "THEN" 
     ], 
     "result.resField1": [ 
      "SPEED", 
      "SPEED" 
     ], 
     "result.resOperator1": [ 
      "EQUALS", 
      "GREATER" 
     ], 
     "result.resVal1": [ 
      100, 
      1000 
     ], 
     "result.resVal2": [ 
      200, 
      2000 
     ], 
     "id": "ed0af96b-5127-4686-ae4c-26621b941919", 
     "_version_": 1541533921419722800 
     } 

,我們可以存儲JSON對象和JSON對象的數組中的Solr類似彈性搜索。

回答

0

有兩個方面是:

  • 保存原來的結構
  • 索引,以便用於搜索

Elasticsearch已經是內置的,但是Solr的做它通過一些靈活的配置。它在參考指南indexing custom JSON下有描述。基本上,原始結構進入_src_字段。索引可以以幾種不同的方式發生,但默認情況下只會將所有內容轉儲到文本字段中,這實際上是Elasticsearch所做的。

請務必記住,兩者都使用下面不支持嵌套結構的Lucene。所以,這兩個引擎都可以在表示和Lucene實際上可以做的之間進行映射。

+0

好的。有一個設置JSON默認值,我們需要把這個xml –

+0

它進入solrconfig.xml,旁邊的其他類似的定義。 –