I need to add multiValued field which will be structure. Something like:
where:
class ComplexPhone [
String area;
String number;
String internal;
String type;
]
I want to receive this data from SOLR in json in format like this:
{
"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 only example ( I do not want to have only phone numbers ).
Most important for me is format of response from SOLR. I can add this data in any plain format like: Funky, Koval, UK; 1234-5678; 9001; L, US; 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 stored in SOLR as a string. All I need is response in more complicated format then flat structure mapped to JSON.
Any advice will be appreciated.
General Properties Solr supports for any field type. Field Default Properties that can be specified on the field type that will be inherited by fields that use this type instead of the default behavior. The name of the fieldType.
The field type defines how Solr should interpret data in a field and how the field can be queried. There are many field types included with Solr by default, and they can also be defined locally. Topics covered in this section:
Where you see class="solr.TextField", this is where Solr points to a class of code that processes Fields of that type, in this case text. There are 21 such classes provided by Solr version 7 listed below. 3. Options for the Different fieldType Classes in Apache Solr
The Solr field-guessing functionality added fields and fieldTypes as it built a schema for us. The end result was an index with unnecessary overlap. A bloated index like this would slow an application, for example, if we added hundreds or thousands of documents to it.
Solr supports multuValued fields. But it doesn't support multilevel data structure. You can not get the following type of response from Solr.
"phone": [
{
"area": "US",
"number": "555-123-456-789",
"internal": "011,
"type": "S",
},
{
"area": "UK",
"number": "1234-5678",
"internal": "9001",
"type": "L",
}
What multiValued field provides is like
"phone": [
"UK",
"1234-5678",
"9001",
"L"
]
Suggestions :
You can refer What is the use of "multiValued" field type in Solr?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With