If I've understood you correctly, you could achieve this also with the
XSLTResponseWriter, it would be pretty trivial to write an XLST that
exposes the node position in the results, containing:

<position><xsl:value-of select="position()"/></position>

Stick that in solr/conf/xslt, and reference it with wt=xslt&tr=xxxx.xsl

That way you wouldn't need to modify Solr at all.

Also, look in Solr 4.0, which has calculated fields. Not sure if there's
the scope to find the document position as a function query though.

Upayavira

On Mon, Oct 8, 2012, at 05:02 AM, deniz wrote:
> well basically i was about to explain and ask once more for your opinions
> but
> this morning i just wanted to try something in the source code and it
> succeeded... so here is what i want and i did for getting it:
> 
> 
> What I wanted: .
> 
> The exact thing I want to is similar to "score" field. Normally it always
> exists but we can see it in a normal query response, unless we set
> fl:*,score. 
> For my case, I would like to see each documents position in a pseudo
> field
> like "score", so when i run a query with fl:*,position I want to see
> <position>5</position> for the 5th document in the result set.
> so to make it more clear when you search for
> "q=name:deniz&fl=*,position,score" the result set will be something like
> :
> 
> <doc><position></position>1<id>986</id><score>5</score></doc>
> <doc><position></position>2<id>1002</id><score>4</score></doc>
> <doc><position></position>3<id>140</id><score>3</score></doc>
> 
> and when user runs another query lets say
> "q=name:stephan&fl=*,position,score" the result set will be like:
> 
> <doc><position></position>1<id>140</id><score>8</score></doc>
> <doc><position></position>2<id>986</id><score>5</score></doc>
> <doc><position></position>3<id>1002</id><score>1</score></doc>
> 
> as you see, each time a different query will have different score,
> therefore
> a documents position - or ranking whichever you prefer to say - will be
> changed according to query
> 
> 
> What I did:
> 
> well after digging the source code, I am now able to see dynamic
> positions
> for each different search.. I have simply added a position function to
> DocIterator and implemented in in subclasses. Then I have added a control
> block in ReturnFields for checking if fl has position in it. It is
> working
> in a similar way with score. and the last thing to do was adding a custom
> augmenter class like PositionAugmenter - similar to ScoreAugmenter. Then
> I
> am done :) 
> 
> I hope it helps if anyone faces a similar issue...
> 
> 
> 
> 
> -----
> Zeki ama calismiyor... Calissa yapar...
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Adding-a-new-pseudo-field-tp4011995p4012375.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to