I have created a core, secondCore{id, resid, title, name, cat, role, exp}
Consider a sample data: {"id" : "11","resid" : 384,"title" : "perl and java developer","name" : "appnede new name","cat" : "22,11","role" : "new role","exp" : 1 }
.
When I search for title:perl
, I get 0 result. I get mentioned result, only if I search for title:"perl and java developer"
or title:perl*
.
Response:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2</int>
<lst name="params">
<str name="indent">true</str>
<str name="q">title:perl*</str>
<str name="_">1444371225114</str>
<str name="wt">xml</str>
</lst>
</lst>
<result name="response" numFound="1" start="0">
<doc>
<str name="id">11</str>
<arr name="resid">
<long>384</long>
</arr>
<arr name="title">
<str>perl and java developer</str>
</arr>
<arr name="name">
<str>appnede new name</str>
</arr>
<arr name="cat">
<long>2211</long>
</arr>
<arr name="role">
<str>new role</str>
</arr>
<arr name="exp">
<long>1</long>
</arr>
<long name="_version_">1514531870450122752</long></doc>
</result>
</response>
Also, why response is in arr <arr name="role"><str>new role</str></arr>
? I want it in <str name="role">new role</str>
and so with other fileds also. How to do? I'm using solr 5.3.0.
Resolved above thing. I have changed field type to
text_general_new
, a new fieldType similar totext_general
with some customization.Alternatively, you can use
text_general
withmultiValued="false"
. These changes needs to be done inmanaged-schema
file. This is an implicit schema file used by solr.But I have one more doubt here, as a beginner. Solr implicitly used managed-schema as replacement of schema.xml, but from where it came to know about fields in JSON file? I mean, it have already defined field for each field present in my JSON. How did it came to know? Which file (with location) is responsible for this?
I think you have defined your field as string instead of text. String field does exact match whereas a text field will get you the results you are looking for.
Check out this other answer also : https://stackoverflow.com/a/7187441/147306