Solr: indexing on the example films doesn't return any result - solr

I just started to learn Solr, when I create the index on the "films" example, I got only 5 documents in Solr Admin which is of course wrong. Here are the steps from Steve Rowe that I followed:
bin/solr stop
rm server/logs/*.log
rm -Rf server/solr/films/
bin/solr start
bin/solr create -c films
curl http://localhost:8983/solr/films/schema -X POST -H 'Content-type:application/json' --data-binary '{
"add-field" : {
"name":"name",
"type":"text_general",
"multiValued":false,
"stored":true
},
"add-field" : {
"name":"initial_release_date",
"type":"pdate",
"stored":true
}
}'
bin/post -c films example/films/films.json
curl http://localhost:8983/solr/films/config/params -H 'Content-type:application/json' -d '{
"update" : {
"facets": {
"facet.field":"genre"
}
}
}'
I got nothing when I do my search:
http://192.168.112.141:8983/solr/films/browse?q=batman
What am I missing here? I even tried to remove solr and reinstall it with no success.
From SolAdmin I can see 1100 docs are there in the core.
Thank you very much, any clue is appreciated.

When you are doing the query q=batman you mention no field to search against. Usual Solr syntax is field:value. In your case I assume it should be q=name:batman
As additional information - when no field is specified, Solr picks up the default field from the configuration, but most likely in your case, it was the field that is not existing in the index.

Related

Update the value of a specific field in solr

I am trying to update the value of existing field in solr document to a new value using curl.Below is the query and response. But I do not see the value for code getting reflected in solr. Please help to resolve the issue.
curl -X POST -H 'Content-Type: application/json' 'http://localhost:8390/solr/collection/update' -d '[{"id" : “12345”,”code” : {"set" : “500”}}]’
{
"responseHeader":{
"rf":1,
"status":0,
"QTime":11}}
Looks like you have missed the commit=true in your request and hence the issue.
Try the below command and hopefully it should work for you.
curl -X POST -H 'Content-Type: application/json' 'http://localhost:8390/solr/collection/update?commit=true' -d '[{"id" : “12345”,”code” : {"set" : “500”}}]’
{
"responseHeader":{
"rf":1,
"status":0,
"QTime":11}}

org.apache.solr.common.SolrException Stream Body is disabled

I have setup apache solr 7.1 and using postman tool to query it. But when I am trying to delete indexed data using postman I get following error.
Request:
GET http://localhost:8983/solr/solr-sample3/update?stream.body={
"delete": {
"query": "*:*"
},
"commit": { }
}
Body:
{
"error": {
"metadata": [
"error-class",
"org.apache.solr.common.SolrException",
"root-error-class",
"org.apache.solr.common.SolrException"
],
"msg": "Stream Body is disabled. See http://lucene.apache.org/solr/guide/requestdispatcher-in-solrconfig.html for help",
"code": 400
}
}
It was working in previous solr version solr 6.6. I went through the lucene documentation but I am not able to figure it out.
You don't need to enable the stream body. Just use a curl POST request specifying the data type as text/xml
curl http://localhost:8983/solr/solr-sample3/update?commit=true -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
Or if you're using the Post Tool included in solr:
bin/post -c core_name -type text/xml -out yes -d $'<delete><query>*:*</query></delete>'
I went though the documentation, it says i need to enable stream body as it has been disabled in solr 7.1 .
to enable use :
curl http://localhost:8983/solr/solr-sample3/config -H 'Content-type:application/json' -d'{
"set-property" : {"requestDispatcher.requestParsers.enableRemoteStreaming":true},
"set-property" : {"requestDispatcher.requestParsers.enableStreamBody":true}
}'
Here is what worked for me, using cURL and avoiding to enable stream body:
curl http://localhost:8983/solr/solr-sample3/update?commit=true -X POST -H "Content-Type: text/xml" --data-binary "<delete><query>*:*</query></delete>"

solr highlighting shows empty result

Hi I am new in Solr and using Solr 7.0.0 running in windows 7.
I created a collection and indexed folder with pdf and html files residing in a folder using the following command:
> java -jar -Dc=guidanceDoc -Dauto example\exampledocs\post.jar M:\Projects\guidance\documents\*
If I write a query, I get results. However, if I turn the hl=on, I get a section for highlights without any text.
Here is the query:
http://localhost:8983/solr/guidanceDoc/select?hl.fl=_text_&hl=on&%20q=_text_:"Home%20Use"
Here is the highlight part of the result:
"highlighting":{
"M:\\Projects\\g1\\documents\\gg331681":{},
"M:\\Projects\\g1\\documents\\gg209337":{},
"M:\\Projects\\g1\\documents\\ggM380327":{},
"M:\\Projects\\g1\\documents\\gg470201":{},
"M:\\Projects\\g1\\documents\\gg507278":{},
"M:\\Projects\\g1\\documents\\gg073767":{},
"M:\\Projects\\g1\\documents\\gg380325":{},
"M:\\Projects\\g1\\documents\\gg484345":{},
"M:\\Projects\\g1\\documents\\gg259760":{}}}
How can I make it work?
Your field for a highlighting should be marked as stored=true. Since you're running Solr in cloud mode, I will recommend to use Schema API to change field definition:
curl -X POST -H 'Content-type:application/json' --data-binary '{
"replace-field":{
"name":"hl_field",
"type":"text",
"stored":true }
}' http://localhost:8983/solr/guidanceDoc/schema

Error when adding user for Solr Basic Authentication

When I try to add the user for the Solr Basic Authentication using the following method in curl
curl --user user:password http://localhost:8983/solr/admin/authentication -H 'Content-type:application/json' -d '{
"set-user": {"tom" : "TomIsCool" ,
"harry":"HarrysSecret"}}'
I get the following error:
{
"responseHeader":{
"status":400,
"QTime":0},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"No contentStream",
"code":400}}
curl: (3) [globbing] unmatched brace in column 1
枩]?V7`-{炘9叡 t肤 ,? E'qyT咐黣]儎;衷 鈛^W褹?curl: (3) [globbing] unmatched cl
ose brace/bracket in column 13
What does this error means and how should we resolve it?
I'm using SolrCloud on Solr 6.4.2.
Regards,
Edwin
If you're using curl under Windows, this is a known issue with cmd.exe's escaping of single quotes. Use double quotes around your JSON string (or use cygwin, powershell, etc.)
curl --user user:password http://localhost:8983/solr/admin/authentication -H
"Content-type:application/json" -d "{
\"set-user\": {\"tom\" : \"TomIsCool\" ,
\"harry\":\"HarrysSecret\"}}"
The "globbing" message from curl is the hint that curl is doing something else than what you intended, and that the actual body of the request isn't getting to Solr (which is complaining about no message body being present).
You could also get around this by using stream.body in the URL and making the request from your browser.

SolrCloud in production - querying q=* gives numFound=0

So I have a three-node cluster deployed using a zookeeper. And successfully created test collection (3 shards). Then after I have
curl -X POST -H 'Content-Type: application/json' 'ec2FirstNodeIP:8983/solr/test/update' --data-binary ' [ { "f1" : "1", "f2" : "2", "f3" : "3" } ]'
I got
{"responseHeader":{"status":0,"QTime":38} ...
However when I have curl "sameIP:8983/solr/test/select?wt=json&indent=true&q=*:*"
I am getting
NumFound:0
But using the admin UI for updating the document, the query now returns the document
image for admin UI
What am I missing?
To make document searchable we should commit. use commit=true
ec2FirstNodeIP:8983/solr/test/update?commit=true this should work.

Resources