SOLR是否支持复合类型,例如multiValued字段的结构?

THM*_*THM 6 json solr types structure

我需要添加multiValued字段,它将是结构.就像是:

哪里:

class ComplexPhone [
    String area;
    String number;
    String internal;
    String type;
]
Run Code Online (Sandbox Code Playgroud)

我希望以这样的格式从json中的SOLR接收这些数据:

{
  "responseHeader": {
    "status": 0,
    "QTime": 1,
    "params": {
      "indent": "true",
      "q": "*:*",
      "_": "1394008742077",
      "wt": "json"
    }
  },
  "response": {
    "numFound": 1,
    "start": 0,
    "docs": [
      {
        "first_name": "Funky",
        "last_name": "Koval",
        "phone": [
          {
             "area": "US",
             "number": "555-123-456-789",
             "internal": "011,
             "type": "S",

          },
          {
             "area": "UK",
             "number": "1234-5678",
             "internal": "9001",
             "type": "L",

          }
        ]
        "id": 1,
        "_version_": 1461724104955527200
      }
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

这只是一个例子(我不想只有电话号码).

对我来说最重要的是SOLR的响应格式.我可以用任何简单的格式添加这些数据,如:Funky,Koval,UK; 1234-5678; 9001; L,美国; 555-123-456-789; 011; S或

<doc>
<field name="first_name">Funky</field>
<field name="last_name">Koval</field>
<field name="phone">UK; 1234-5678; 9001; L</field>
<field name="phone">US; 555-123-456-789; 011; S</field>
<field name="id">1</field>
</doc>
Run Code Online (Sandbox Code Playgroud)

它可以作为字符串存储在SOLR中.我需要的只是更复杂格式的响应,然后平面结构映射到JSON.

任何建议将被认真考虑.

bud*_*y86 2

Solr 支持多值字段。但它不支持多级数据结构。您无法从 Solr 获得以下类型的响应。

"phone": [
          {
             "area": "US",
             "number": "555-123-456-789",
             "internal": "011,
             "type": "S",

          },
          {
             "area": "UK",
             "number": "1234-5678",
             "internal": "9001",
             "type": "L",

          }
Run Code Online (Sandbox Code Playgroud)

multiValued 字段提供的内容如下

"phone": [
          "UK",
          "1234-5678",
          "9001",
          "L"
        ]
Run Code Online (Sandbox Code Playgroud)

建议:

  1. 您可以以更简单的方式设计数据,以便它可以适合 Solr 提供的单值/多值字段。
  2. 将复杂的结构化数据作为字符串或某种合适类型的字段保存在 Solr 中。在您的应用程序中解析数据以获取实际值。

你可以参考Solr中“multiValued”字段类型有什么用?