How to fetch Payload field value from Solr Query - solr

In My Solr Collection , I have field of type "Payload" and I wanted to see the value stored in specific document . Can you please suggest if there is any way to get the payload field value using Solr Query ?
I tried putting the field name in "fl" parameter list of Solr query but it does not return me Payload field in the result.
Please advice ?

Make sure field is stored. check in schema.xml file if Payload field is set stored="true"
<field name="Payload" type="text_general" indexed="true" stored="true"/>
if it is set to false, change it to true, restart solr and reindex you content. you see Payload field in your results.

Related

Solrj indexing mechanism

I have a question about indexing mechanism using Solr in Java. If I create a documents and i want to find only field "name", solr will be index all fields? Or only index by field "name" in each document?
If you tell Solr to only store the field name in your schema, then only the field name will be stored.
If you instruct Solr to store everything you send to it (like in the schemaless mode) and you send 400 fields, each of those fields will be stored.
If you want to store information but not search for it, only those fields which you are going to query need to be indexed, while the other fields can be limited to just stored. If you don't need the content of the field, but just want to search for it, you can set stored to false, and indexed to true.
In the schema.xml where you define the fields getting used, you need to mention indexed=true for all the fields you want to search on.
In your case it would look something like this -
<field name="name" type="string" indexed="true" stored="true" />

On the fly field value calculation in Solr

I've 10s of fileds defined in my Solr manaed-schema, out of those two are as below:
<field name="isBookmarked" type="boolean" indexed="true" stored="true" required="false" multiValued="false" />
<field name="bookmarkedPathologists" type="string" indexed="true" stored="true" required="false" multiValued="true" />
Now, here I want to set isBookmarked value to 'true' OR'false' if bookmarkedPathologists has SOME value passed while querying on the fly.
Post that I'm sorting on isBookmarked field.
Is it possible? Help anticipated
I struggled a lot and finally got luck to solve my problem using below possible solution.
As on the fly updated changes need to be committed to Solr before getting sorted result on and hence my application which is Solr Client, couldn't get updated/dirty values to sort on, if any.
So I added a Filter Query to my Simple Query Criteria as * exists(query({!v='bookmarkedPathologists:patho'})) : will filter my all(*) results with new on the fly created field named as exists(query({!v='bookmarkedPathologists:patho'})) in JSON response as below:-
:
:
"isBookmarked": false,
"bookmarkedPathologists": [
"patho1"
],
:
:
"_version_": 1582235372763480000,
"exists(query({!v='bookmarkedPathologists:patho'}))": false
Post that I just put sort-order over the same i.e. exists(query({!v='bookmarkedPathologists:patho'})) as exists(query({!v='bookmarkedPathologists:patho'})) asc
So Solr returned sorted response over exists(query({!v='bookmarkedPathologists:patho'})).
Solr Function Query helped me a lot from Function Queries
As I understand you want to update the field while querying the data from it.
SOLR programmed in java language and to interface with SOLR is done using REST kind of services.
And service for search is on:
/solr/<CollectionName>/select
And service for update is on:
/solr/update
So you can`t do both with using same query.
But you want to update externally (using other query) then refer.

SOLR Exact match issue

I have indexed my field in SOLR using field type "string".
My field contains two values "APA" and "APA LN".
I have queried SOLR with q=field:"APA".
With the above query i ma getting the results for both APA and APA LN.
I have to query SOLR to just get "APA".
Any help is appreciated
I presume that your field "field" is TextField or text_general. Can you change it to string and try again?
ie something like this
<field name="customfield" type="string" indexed="true" stored="true" multiValued="false" />
It should not be happening for a type string. The most likely scenario is that you did not fully reindex or did not commit after reindexing.
You can check what your field actually contains in the Admin UI's Schema Browser screen (press load term info).

Solr field not visible in query results

I have added a new field in the schemas:
<field indexed="false" stored="true" docValues="true" sortMissingLast="true" name="RankScoreXXX" type="int" />
After all the indexing operations are done, in the solr admin panel while performing queries I do not see that field in any results where the value is actually 0. Results that contain a > 0 value in this specific field are shown.
By using this parameter I can see that none result does not contain this value
fq: -RankScoreXXX: [* TO *] .Also, I can sort results by this specific field.
I just do not understand why results with RankScoreXXX = 0 are not visible in the solr panel admin for given results.
Am I missing something?
Thanks.
I have ran into this scenario a few times. Let me tell you what each one was:
Field was added but reindexing did not take place for all documents, only new ones. This is not your case as you reindexed.
Request handler was not updated in solrconfig.xml. In this case the person added the field and had configured the request handler to return a specific number of fields using fl. The field was not in the list.

Sort on field completeness of Solr Documents

I have this Solr field
<field name="listing_thumbnail" type="string" indexed="false" stored="true"/>
Now when the results are shown the fields without the field value should be shown at the last. Is this possible in SOLR? To generalise is it possible to sort documents on field completeness?
You can make use of bq (Boost Query) Parameter of the dismax/edismax query handler. This allows to query if a field is empty or not and then affect the score, but to do so the field needs to be indexed=true.
If you had your field indexed you could add bq=(listing_thumbnail:*) - this would give a push to all documents with a value in that field.

Resources