0

I have a Spring Boot Application and I am trying to store data directly to Solr. Following is my Solr Model class

public class AnalyticsGeoLocationSolr {

    @Id
    @Indexed(name = "id", type = "int")
    private Integer id;

    @Indexed(name = "ipaddress", type = "string") // defined as String
    private String ipAddress;

    @Indexed(name = "country_name", type = "string") // defined as String
    private String countryName;

// Getters and Setters

Here you can see that ipAddress and CountryName both are defined as String as type="string". However, the Solr is saving these variables as an array of String. Following is display of these fields in Solr (as Json):

"ipAddress":["59.103.217.207"],
"countryName":["Pakistan"],
// Other fields

enter image description here


Now, I want these String Objects to be stored as string i.e the expected Output should be "ipAddress":"59.103.217.207" not an array (with [ ] around).
Eatsam ul haq
  • 317
  • 1
  • 12
  • The question is similar to https://stackoverflow.com/questions/58388829/spring-data-solr-is-creating-fieldtype-as-text-general-even-though-we-mention-as – Eatsam ul haq Oct 14 '22 at 15:53
  • Check if this helps: https://stackoverflow.com/questions/37042732/solr-text-indexed-as-array-of-text – pringi Oct 14 '22 at 15:58
  • 1
    @pringi thanks for replying. Yes this is the way to solve the problem but this approach is possible to manually change data type in solr schema. I am looking a way to do this in `spring boot` – Eatsam ul haq Oct 16 '22 at 15:26

0 Answers0