Solr HTTP Api - response status - solr

When using SOLR via his HTTP Api, he responds with an object called responseHeader where he puts the status of the response
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">13</int>
<!-- ... -->
</lst>
<!-- ... -->
</response>
My first question: What are the possible values of the status attribute? and what are their meanings?. I know that the value 0 means a successful call.
My second question: Normally, Solr responds with an 200 code for a successful call. Can we get a status different than 0 (in case of an error) and still get 200 for the http response code?
I use SOLR 4.6
Nb: I asked those questions cause my SOLR doesn't index somme of the collections although he doesn't rise any error and the response code is 200!
Thank you

The status code usually corresponds to the HTTP code given back, except for 200 being returned as 0. This is implemented as the numeric code when a SolrException is thrown interally in Solr. When this was asked on the solr-user mailing list a while back, the following answer from Erik Hatcher was given:
Is there a reference to this status-codes?
Just the source code. SolrCore#setResponseHeaderValues, which predominately uses the codes specified in SolrException:
BAD_REQUEST( 400 ),
UNAUTHORIZED( 401 ), // not currently used
FORBIDDEN( 403 ),
NOT_FOUND( 404 ),
SERVER_ERROR( 500 ),
SERVICE_UNAVAILABLE( 503 ),
UNKNOWN(0);
The current version of SolrCore can be seen on Github.
You can probably assume that the http error code will match the status value most of the time, but there's certainly exceptions - for example if the HTTP request never reaches Solr at all, and the error is just returned by jetty instead (if the installations is severely borked, or possibly if you try to access something other than /solr).
In your example, the request can be perfectly fine and OK, even if the action doesn't trigger anything when importing data to a collection. If your import query ends up in 0 documents, that isn't an error - and if the import started (an import is usually a async operation), that's still a valid and OK request, even if the end result later isn't valid.
It's probably better to try to understand why your import is failing (and use a separate question for that with all the relevant details about how you're trying to index, what any errors in the log say (you can adjust the log level under Logging in the web interface) and what you expected the result to be), instead of looking at the status field in the response.

Related

Error adding field 'field_name'-'field_value' msg=For input string: \"field_Value\"

We are struggling to import certain files into Solr occasionally. It seems like certain documents have weird meta data (values), not sure if it might be from eccentric word processor or something else. See two examples here:
Type: Solarium\Exception\HttpException
Message: Solr HTTP error: OK (400)
{"responseHeader":{"status":400,"QTime":49},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","java.lang.NumberFormatException"],"msg":"ERROR: [doc=3932487729] Error adding field 'brightness_value'='6.18' msg=For input string: \"6.18\"","code":400}}
And
Type: Solarium\Exception\HttpException
Severity: error --> Exception: Solr HTTP error: OK (400)
{"responseHeader":{"status":400,"QTime":72},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","java.lang.NumberFormatException"],"msg":"ERROR: [doc=16996] Error adding field 'version'='5.3.1' msg=For input string: \"5.3.1\"","code":400}}
How do we prevent these issues? We are not in control of the documents, so need to fix it on the server.
Define the field type explicitly in the schema instead of relying on Solr to create the field type for you - the first document that contains the field will make Solr guess the type of the field, and if later documents doesn't match the same, expected format, you'll get an error like this.
Always define the schema for a collection when using it in production or in an actual application - the schemaless mode is really neat for prototyping and experimenting, but in an actual application you want the types to be well defined.

Thunderbird Lightning caldav sync doesn't show any data/events

when i try to synchronize my caldav server implementation with Thunderbird 45.4.0 and Lightning 4.7.4 (one particular calendar collection) it doesnt show any data or events in the calendar though the last call of the sequence provided the data.
In the Thunderbird error log i can see one error:
Zeitstempel: 07.11.16, 14:21:12
Fehler: [calCachedCalendar] replay action failed: null,
uri=http://127.0.0.1:8003/sap/sports/webdav/appsvc/webdav/services/
server.xsjs/cal/_D043133/, result=2147500037, op=[xpconnect wrapped
calIOperation]
Quelldatei:
file:///Users/d043133/Library/Thunderbird/Profiles/hfbvuk9f.default/
extensions/%7Be2fda1a4-762b-4020-b5ad-a41df1933103%7D/calendar-
js/calCachedCalendar.js
Zeile: 327
the call sequence is as follows (detailed content via gist-links):
Propfind Request - Response
Options Request - Response
Propfind Request - Response
Report Request - Response - Response Raw
The synchronization with other clients like macOS-calendar and ios-calendar works in principle and shows the data. Does anyone has a clue what is going wrong here?
Not sure whether that is the cause but I can see two incorrect things:
a) Your <href/> property has trailing spaces:
<d:href>/sap/sports/webdav/appsvc/webdav/services/server.xsjs/cal/_D043133/EVENT%3A070768ba5dd78ff15458f1985cdaabb1.ics
</d:href>
b) your ORGANIZER property is not a valid URI
ORGANIZER:_D043133
i was able to find the cause of the above issue by debugging Thunderbird as propsed by Philipp. The Report Response has http status code 200, but as it is a multistatus response Thunderbird/Lightning expects status code 207 ;-)
Thanks for the hints!

Solr: where to find the Luke request handler

I'm trying to get a list of all the fields, both static and dynamic, in my Solr index. Another SO answer suggested using the Luke Request Handler for this.
It suggests finding the handler at this url:
http://solr:8983/solr/admin/luke?numTerms=0
When I try this url on my server, however, I get a 404 error.
The admin page for my core is here http://solr:8983/solr/#/mycore, so I also tried http://solr:8983/solr/#/mycore/admin/luke. This also gave me another 404.
Does anyone know what I'm doing wrong? Which url should I be using?
First of all you have to enable the Luke Request Handler. Note that if you started from the example solrconfig.xml you probably don't need to enable it explicitly because
<requestHandler name="/admin/" class="solr.admin.AdminHandlers" />
does it for you.
Then if you need to access the data programmatically you have to make an HTTP GET request to http://solr:8983/solr/mycore/admin/luke (no hash mark!). The response is in XML but specifying wt parameter you can obtain different formats (e.g. http://solr:8983/solr/mycore/admin/luke?wt=json)
If you only want to see fields in SOLR web interface select your core from the drop down menu and then click on "Schema Browser"
In Solr 6, the solr.admin.AdminHandlers has been removed. If your solrconfig.xml has the line <requestHandler name="/admin/" class="solr.admin.AdminHandlers" />, it will fail to load. You will see errors in the log telling you it failed to load the class org.apache.solr.handler.admin.AdminHandlers.
You must include in your solrconfig.xml the line,
<requestHandler name="/admin/luke" class="org.apache.solr.handler.admin.LukeRequestHandler" />
but the URL is core-specific, i.e. http://your_server.com:8983/solr/your_core_name/admin/luke
And you can specify the parameters fl,numTerms,id,docId as follows:
/admin/luke
/admin/luke?fl=cat
/admin/luke?fl=id&numTerms=50
/admin/luke?id=SOLR1000
/admin/luke?docId=2
You can use this Luke tool which allows you to explore Lucene index.
You can also use the solr admin page :
http://localhost:8983/solr/#/core/schema-browser

Solr Adding PDF via ExtractRequestHandler

I am trying to use the Solr handler to add a PDF document to the index but keep getting a missing Unique field error (even though I am providing the field). Here is the request:
D:\Downloads\solr-4.6.0\solr-4.6.0\example\exampledocs>c:\temp\curl "http://loca
lhost:8983/solr/update/extract?commit=true&literal.MessageID=2b071dce-d7a6-4b7c-
9a09-33cc93f96db9" -F "myfile=#Wizards vs Warriors tickets.pdf"
The error I get back is:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">400</int><int name="QTime">135</in
t></lst><lst name="error"><str name="msg">Document is missing mandatory uniqueKe
y field: MessageID</str><int name="code">400</int></lst>
</response>
In my REST call I am using literal.MessageID=... but it still seems to not find it.
Any ideas on how I can troubleshoot this? (NOTE: I did find an article on SO about problems with fields ending in ID so I removed the ID from the field in the schema and modified the literal.Message but still same issue.
Thanks,
I tried your test case and found the same result. Then I did several test cases and found that the required unique key field name should be always in lowercase. That's why when you try with MessageID, it doesn't work.
Try with messageid. It'll work.

URL returned non 200 response code

I am Indexing Documents by using SolrPhpClient library. while making POST request by Solr using extract function reply with
URL http://localhost/moodledemo/pluginfile.php/99/course/overviewfiles/pre bio- data.docx returned non 200 response code".
It happens only if the file name include space. if the filename don't have any space it goes well.
I don't conclude why it returns non 200 response with files that have space in their names. while accessing the same path works in browser.
Using rawurlencode() Solved the Issue..
may be the jetty server was responding with non 200 response code with the filename:-
How are you.doc
Using rawurlencode()
How%20are%20you.doc
Thanks :)

Resources