3

I am trying to integrate Spring Data solr into my spring application and I have strucked with the below problem.

Even though I have added the type=string in @Indexed property it is still creating the field type as "text_general".

Any inputs?

@SolrDocument(collection = "product")
 public class Product {
@Id
private String id;

@Indexed(name="name",type = "string")
private String name;
}

In Solrschema file it is showing as:

<field name="name" type="text_general"/>

Any thoughts?

Thanks.

sree
  • 868
  • 2
  • 12
  • 35
  • Have you completely reset the core/collection by deleting and re-creating it? Otherwise the field will (usually) be as it was defined the first time. – MatsLindh Oct 15 '19 at 11:48
  • yes, I have removed collection and performed the Index. The collection got created and having the same issue. – sree Oct 15 '19 at 11:53
  • How are you creating the schema? Have you enabled `schemaCreationSupport` for your `@EnableSolrRepositories`? https://stackoverflow.com/questions/39791966/enable-schemacreationsupport-in-spring-boot-starter-data-solr – MatsLindh Oct 15 '19 at 13:36
  • @MatsLindh I tried it and still the same issue. – sree Oct 16 '19 at 07:29
  • You'll have to start by finding out how the schema is created - if the schemaless mode is active, then the fields will be created as `text_general` if they're not present in Solr before data arrives and the data looks like text. If you want a field to be a `string` field, it'll need to be explicitly created in that way, either from Spring Data (which is what the answer linked above should do as far as I know), or by manually creating or uploading a schema before indexing. You can disable the schemaless mode when testing, as it'll then error out if an undefined field is submitted. – MatsLindh Oct 16 '19 at 07:37
  • If that's the case, then Spring Data isn't creating any fields and it's Solr doing all the work behind the scenes. Any decorator in Spring Data won't affect what Solr is doing in that case. – MatsLindh Oct 16 '19 at 07:38

0 Answers0