Fields in apache solr reaction are ambiguous when they should be singular

I am having a problem with Apache Solr where I get fields wrapped in lists in JSON responses, but they should be the only ones. Here is an example from schema.xml, two example fields that ask me the problem: django_ct and django_id :

  <fields> <!-- general --> <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/> <field name="django_ct" type="string" indexed="true" stored="true" multiValued="false"/> <field name="django_id" type="string" indexed="true" stored="true" multiValued="false"/> 

Here is an example of how data is sent to Solr:

 <doc> <field name="id">search.productcategory.3</field> <field name="gender">M</field> <field name="name">OBQYHSOQLWOUEHRMPSDI</field> <field name="text">M\nOBQYHSOQLWOUEHRMPSDI</field> <field name="django_id">3</field> <field name="django_ct">search.productcategory</field> </doc> 

And here is an example of a file stored in solr:

  "response": { "numFound": 1, "start": 0, "docs": [ { "django_ct": [ "search.productcategory" ], "name": [ "Example" ], "text": [ "Male\nExample" ], "id": "search.productcategory.2", "gender": [ "Male" ], "django_id": [ 2 ], "_version_": 1502081283634757600 } ] } 

What causes these fields to be wrapped in lists? In the schema, the multiValued attribute for these fields is false. Besides creating a kernel and replacing schema.xml, everything else is right out of the box. I turn to Solr using Haystack (the Django plugin), the code expects to get separate values ​​for these fields, but it is completely broken by this. Tracking the problem seems to be related to setting up Solr.

Edit: here is the full contents of solr.log, all this was logged after the server started, there was no output when starting a few sample requests:

 INFO - 2015-05-27 08:38:12.563; [ ] org.eclipse.jetty.server.Server; jetty-8.1.10.v20130312 INFO - 2015-05-27 08:38:12.586; [ ] org.eclipse.jetty.deploy.providers.ScanningAppProvider; Deployment monitor /Users/sampeka/solr-5.1.0/server/contexts at interval 0 INFO - 2015-05-27 08:38:12.593; [ ] org.eclipse.jetty.deploy.DeploymentManager; Deployable added: /Users/sampeka/solr-5.1.0/server/contexts/solr-jetty-context.xml INFO - 2015-05-27 08:38:13.629; [ ] org.eclipse.jetty.webapp.StandardDescriptorProcessor; NO JSP Support for /solr, did not find org.apache.jasper.servlet.JspServlet INFO - 2015-05-27 08:38:13.682; [ ] org.apache.solr.servlet.SolrDispatchFilter; SolrDispatchFilter.init() WebAppClassLoader=1121453612@42d8062c 
+6
source share
1 answer

Get to the root of the problem. The problem was that solrconfig.xml not configured correctly. By default, the schemafactory class is schemafactory to ManagedIndexSchemaFactory , which overrides the use of schema.xml . Changing the schemafactory to the ClassicIndexSchemaFactory class, it forces the use of schema.xml and makes the schema unchanged by API calls.

+7
source

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


All Articles