Solr创建Core,它具有类似于弹性搜索的Json对象和Json对象

时间:2016-08-02 07:44:43

标签: json solr

我想创建一个拥有doc

下的doc的核心
{
  "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
      }

我们可以在solr中存储json对象和Json对象数组,类似于弹性搜索。

1 个答案:

答案 0 :(得分:0)

这有两个方面:

  • 存储原始结构
  • 为搜索索引

Elasticsearch内置了它,但Solr通过配置实现了一些灵活性。它在indexing custom JSON下的参考指南中进行了描述。基本上,原始结构进入 _src _ 字段。索引可以通过几种不同的方式进行,但默认只会将所有内容转储到 text 字段,这实际上是Elasticsearch所做的。

重要的是要记住,两者都使用不支持嵌套结构的Lucene。因此,两个引擎都在表示和Lucene实际可以做的事情之间进行映射。