Is SOLR support for complex types, such as a structure for fields with multiple values?

I need to add a multiValued field, which is a structure. Sort of:

     

Where:

class ComplexPhone [
    String area;
    String number;
    String internal;
    String type;
]

I want to get this data from SOLR in json in the following format:

{
  "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
      }
    ]
  }
}

This is just an example (I don't want to have just phone numbers).

Most important to me is the response format from SOLR. I can add this data in any simple format, for example: Funky, Kowal, UK; 1234-5678; 9001; L, USA; 555-123-456-789; 011; S or

<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>

It can be saved in SOLR as a string. All I need is an answer in a more complex format, and then a flat structure mapped to JSON.

Any advice would be appreciated.

+4
source share
1

Solr multuValued. . Solr.

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

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

          }

, ,

"phone": [
          "UK",
          "1234-5678",
          "9001",
          "L"
        ]

:

  • , Solr, / .
  • Solr . , .

"multiValued" Solr?

+1

Source: https://habr.com/ru/post/1530201/


All Articles