JSON 由 Solr 返回

JSON returned by Solr

我正在使用 Solr 来索引我的数据。

通过Solr的UI我在Schemawindow中添加了两个字段:word,messageid

在我进行以下查询后post:

curl -X POST -H "Content-Type: application/json" 'http://localhost:8983/solr/messenger/update.json/docs' --data-binary '{"word":"hello","messageid":"23523}'

我收到以下 JSON:

{
  "responseHeader": {
    "status": 0,
    "QTime": 55
  }
}

当我要在 API 中查询 Window 并执行不带参数的查询时,我得到以下 JSON:

{
  {
    "responseHeader": {
      "status": 0,
      "QTime": 0,
      "params": {
        "q": "*:*",
        "indent": "on",
        "wt": "json",
        "_": "1488911768817"
      }
    },
    "response": {
      "numFound": 1,
      "start": 0,
      "docs": [
        {
          "id": "92db6722-d10d-447a-b5b1-13ad9b70b3e2",
          "_src_": "{\"word\":\"hello\",\"messageid\":\"23523\"}",
          "_version_": 1561232739042066432
        }
    }
  }
}

我的 JSON 不应该更像下面这个吗?:

//More Code
"response": {
  "numFound": 1,
  "start": 0,
  "docs": [
    {
      "id": "92db6722-d10d-447a-b5b1-13ad9b70b3e2",
      "word": "hello",
      "messageid": "23523",
      "_version_": 1561232739042066432
    }
//More Code

为了以后能够通过以下选项使用参数进行过滤?:

事实证明,您使用的是 'custom JSON indexing' 中描述的所谓 here 方法。您可以按照 wiki 中的描述对其进行调整,以提取所需的字段。以下摘录供您参考:

split: Defines the path at which to split the input JSON into multiple Solr documents and is required if you have multiple documents in a single JSON file. If the entire JSON makes a single solr document, the path must be “/”. It is possible to pass multiple split paths by separating them with a pipe (|) example : split=/|/foo|/foo/bar . If one path is a child of another, they automatically become a child document

f: This is a multivalued mapping parameter. The format of the parameter is target-field-name:json-path. The json-path is required. The target-field-name is the Solr document field name, and is optional. If not specified, it is automatically derived from the input JSON.The default target field name is the fully qualified name of the field. Wildcards can be used here, see the section Wildcards below for more information.

但我建议使用标准的文档索引方法,这是来自 here 的旧 update 命令。所以它看起来更像:

 curl 'http://localhost:8983/solr/messenger/update?commit=true' --data-binary '{"word":"hello","messageid":"23523}' -H 'Content-type:application/json'