You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by tkamphuis <to...@hotmail.com> on 2011/09/08 08:34:07 UTC

Using multivalued field in map function

Hi,

I'm working on implementing Solr in a project and right now I'm stuck on a
specific search including an arr field. The thing is:

I'd like to search sub-id's on an object, these sub-id's are stored in a
multivalue field, e.g.:
<arr name="SubIds">
   <int>12272</int>
   <int>12304</int>
   <int>12306</int>
</arr>

The query (or part of the query) that I want to use is as follows:
map(SubIds,i,i,1,0)

When I, for example, fill 12304 on the 'i' space in the map function above,
I would expect my function to return 1. If I would enter 12345 it should
return 0. The thing is that when I run this query it returns 0, or "There's
no number 12304 in this field, I return 0". 

When removing the 0 from my map function I can see the actual value returned
to me (when 12304 return 1, when different return value), in this case
that's 12306! I've tried this with some different multivalued fields but the
result is the same; it looks like the function is checking the last value in
the multivalue field against my filled in ID.

Is this true? And when it does, is there any way in looking through the
whole arr and only return 0 when the value doesn't exist in the whole
multivalued field?

Thanks!

--
View this message in context: http://lucene.472066.n3.nabble.com/Using-multivalued-field-in-map-function-tp3318843p3318843.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Using multivalued field in map function

Posted by Chris Hostetter <ho...@fucit.org>.
: Hmmm, would it be simpler to do something like append
: a clause like this?
: BloggerId:12304^10 OR CoBloggerId:123404^5?

Definitely, but that won't garuntee you a strict ordering if there is a 
particularly good relevany match.

There's a bunch of ways to go about something like this, but trying to use 
the map function is definitely overkill (even if it could work on 
multivalued fields)

this kind of thing is particularly easy with the sort by function feature 
added in 3.2 -- because any query can be used as a function ...

q=your_query&sort=query(BloggerId:12304)+desc,+query(CoBloggerId:123404)+desc,+score+desc


-Hoss

Re: Using multivalued field in map function

Posted by Erick Erickson <er...@gmail.com>.
Hmmm, would it be simpler to do something like append
a clause like this?
BloggerId:12304^10 OR CoBloggerId:123404^5?

Best
Erick

On Fri, Sep 9, 2011 at 2:14 AM, tkamphuis <to...@hotmail.com> wrote:
> Well, I'd like to do the following:
>
> I've got a website full of blogposts and every blogpost has an owner, this
> owner is refererred to through his/her id. For example: BloggerId = 123.
> It's also possible that the blog has multiple co-writers, which are also
> referred to by there BloggerId but these id's are stored in the multivalue
> field, in my previous example SubIds.
>
> When searching for a specific blogger one searches the BloggerId.
> Searchresults are influenced by a number of variables, the
> country/state/more specific geological data, the blogcategory, etc. For this
> I use a facetted query. Next I want to make some results more important,
> depending on the BloggerId, I tried to do this with the following query:
>
> ?q={!func}map(sum(map(BloggerId,12304,12304,2,0),map(BloggerId,12304,12304,1,0)),3,3,2)&fl=*,score&facet.field=Country&f.Country.facet.limit=6&facet.field=State&fq=(BlogCategory:internet%20OR%20BlogCategory:sports&sort=score%20desc,Top%20desc,%20SortPriority%20asc&start=0&omitHeader=true
>
> In the resulting list, blogs written by BloggerId 12304 should be on top of
> the list, followed by the blogs where BloggerId 12304 was co-writer. After
> that, all other blogs that follow the criteria but aren't written (or
> co-written) by BloggerId 12304.
>
> Any ideas? Thanks!
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Using-multivalued-field-in-map-function-tp3318843p3322023.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Using multivalued field in map function

Posted by tkamphuis <to...@hotmail.com>.
Well, I'd like to do the following:

I've got a website full of blogposts and every blogpost has an owner, this
owner is refererred to through his/her id. For example: BloggerId = 123.
It's also possible that the blog has multiple co-writers, which are also
referred to by there BloggerId but these id's are stored in the multivalue
field, in my previous example SubIds.

When searching for a specific blogger one searches the BloggerId.
Searchresults are influenced by a number of variables, the
country/state/more specific geological data, the blogcategory, etc. For this
I use a facetted query. Next I want to make some results more important,
depending on the BloggerId, I tried to do this with the following query:

?q={!func}map(sum(map(BloggerId,12304,12304,2,0),map(BloggerId,12304,12304,1,0)),3,3,2)&fl=*,score&facet.field=Country&f.Country.facet.limit=6&facet.field=State&fq=(BlogCategory:internet%20OR%20BlogCategory:sports&sort=score%20desc,Top%20desc,%20SortPriority%20asc&start=0&omitHeader=true

In the resulting list, blogs written by BloggerId 12304 should be on top of
the list, followed by the blogs where BloggerId 12304 was co-writer. After
that, all other blogs that follow the criteria but aren't written (or
co-written) by BloggerId 12304.

Any ideas? Thanks!

--
View this message in context: http://lucene.472066.n3.nabble.com/Using-multivalued-field-in-map-function-tp3318843p3322023.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Using multivalued field in map function

Posted by Emmanuel Espina <es...@gmail.com>.
Function queries don't work with multivalued field.
http://wiki.apache.org/solr/FunctionQuery#Vector_Functions

You'll have to think in another way of doing that. What do you want to
achieve with that map?

Regards
Emmanuel

2011/9/8 tkamphuis <to...@hotmail.com>

> Hi,
>
> I'm working on implementing Solr in a project and right now I'm stuck on a
> specific search including an arr field. The thing is:
>
> I'd like to search sub-id's on an object, these sub-id's are stored in a
> multivalue field, e.g.:
> <arr name="SubIds">
>   <int>12272</int>
>   <int>12304</int>
>   <int>12306</int>
> </arr>
>
> The query (or part of the query) that I want to use is as follows:
> map(SubIds,i,i,1,0)
>
> When I, for example, fill 12304 on the 'i' space in the map function above,
> I would expect my function to return 1. If I would enter 12345 it should
> return 0. The thing is that when I run this query it returns 0, or "There's
> no number 12304 in this field, I return 0".
>
> When removing the 0 from my map function I can see the actual value
> returned
> to me (when 12304 return 1, when different return value), in this case
> that's 12306! I've tried this with some different multivalued fields but
> the
> result is the same; it looks like the function is checking the last value
> in
> the multivalue field against my filled in ID.
>
> Is this true? And when it does, is there any way in looking through the
> whole arr and only return 0 when the value doesn't exist in the whole
> multivalued field?
>
> Thanks!
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Using-multivalued-field-in-map-function-tp3318843p3318843.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>