On 5/31/2016 10:16 AM, Mark Robinson wrote:
> sorry Eric... I did not phrase it right ... what I meant was the field is
> there in the schema, but I do not have values for it when normal indexing
> happens.
> When a query comes in, I want to populate value for this field in the
> results based on some values passed in the query.
> So what needs to be accommodated in the result depends on a parameter in
> the query and I would like to sort the final results on this field also,
> which is dynamically populated.
>
> What could be the best way to dynamically add value to this field based on
> a query parameter and sort on this field also.

Queries do not normally change the index.  They normally use a Lucene
object that can search the index, not an object that can write to the index.

I do not know whether a custom query component will be able to achieve
write access to the index or not.  If it can, then you *might* be able
to do what you want, but be aware that the index must meet the
requirements for Atomic Update functionality, or the entire idea won't
work at all:

https://wiki.apache.org/solr/Atomic_Updates#Caveats_and_Limitations

I have never written a custom query component, so I cannot say for sure
that this is achievable.

> Will a custom component help, with code in the *process *method to access
> the results one by one and plug in this field help?
> If so do I need to first index the value inside the *process *method for
> reach result or is there a way to just add this value to each of my results
> doc (no indexing) iterating through the result set and plugging in this
> value for each result.

The mention of a "process" method here suggests that you are thinking of
an UpdateProcessor.  This would work if you are indexing ... but above
you said this would happen at *query* time, which is a little bit different.

> How will sort be applicable on this dynamically populated field as I am
> already working on the results and is it too late to specify a sort and if
> so how could it be possible.

I do not know anything about custom code and sorting.

Thanks,
Shawn

Reply via email to