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 Phil Messenger <ph...@miniweb.tv> on 2010/03/26 18:37:48 UTC

Complex relational values

Hi,

I need to store structured information in an index entry for use when 
filtering. As XML, this could be expressed as:

<item>
	<some_fields_that_are_searched_using_dismax />
	<data>
		<item type="foo" x="100" y="200" />
		<item type="bar" x="300" y="1000" />
	</data>
</item>

I want to be able to *filter* search results according to the data in the
"item" tags - eg. show all index entries which match the expression 
"type=foo && x > 100 & y > 500"

Having a multivalued field for type, x and y doesn't seem to work here as 
I need to maintain the relationship between a type/x/y.

I'm not sure how to approach this problem. Is writing a custom field type the 
preferred approach?

thanks,

Phil.


Re: Complex relational values

Posted by Lance Norskog <go...@gmail.com>.
If 'item' is the unique document level, then this can be done with:
unique id: your own design
searchable text fields:
foo_x:
foo_y:
bar_x:
bar_y:

The query becomes:
    foo_x:[100 TO *] AND foo_y:[500 TO *]

Note that to search the other fields with dismax, and foo* with the
standard query parser, you'll need to combine the two with the crazy
multi-parser syntax.

On Fri, Mar 26, 2010 at 10:49 AM, Kumaravel Kandasami
<ku...@gmail.com> wrote:
> I would represent each "item" element as a document, and each attribute as
> the fields of the document.
>
> if the field names are not known upfront, you could create 'dynamic fields'.
>
>
>
>
> Kumar    _/|\_
> www.saisk.com
> kumar@saisk.com
> "making a profound difference with knowledge and creativity..."
>
>
> On Fri, Mar 26, 2010 at 12:37 PM, Phil Messenger <ph...@miniweb.tv> wrote:
>
>> Hi,
>>
>> I need to store structured information in an index entry for use when
>> filtering. As XML, this could be expressed as:
>>
>> <item>
>>        <some_fields_that_are_searched_using_dismax />
>>        <data>
>>                <item type="foo" x="100" y="200" />
>>                <item type="bar" x="300" y="1000" />
>>        </data>
>> </item>
>>
>> I want to be able to *filter* search results according to the data in the
>> "item" tags - eg. show all index entries which match the expression
>> "type=foo && x > 100 & y > 500"
>>
>> Having a multivalued field for type, x and y doesn't seem to work here as
>> I need to maintain the relationship between a type/x/y.
>>
>> I'm not sure how to approach this problem. Is writing a custom field type
>> the
>> preferred approach?
>>
>> thanks,
>>
>> Phil.
>>
>>
>



-- 
Lance Norskog
goksron@gmail.com

Re: Complex relational values

Posted by Kumaravel Kandasami <ku...@gmail.com>.
I would represent each "item" element as a document, and each attribute as
the fields of the document.

if the field names are not known upfront, you could create 'dynamic fields'.




Kumar    _/|\_
www.saisk.com
kumar@saisk.com
"making a profound difference with knowledge and creativity..."


On Fri, Mar 26, 2010 at 12:37 PM, Phil Messenger <ph...@miniweb.tv> wrote:

> Hi,
>
> I need to store structured information in an index entry for use when
> filtering. As XML, this could be expressed as:
>
> <item>
>        <some_fields_that_are_searched_using_dismax />
>        <data>
>                <item type="foo" x="100" y="200" />
>                <item type="bar" x="300" y="1000" />
>        </data>
> </item>
>
> I want to be able to *filter* search results according to the data in the
> "item" tags - eg. show all index entries which match the expression
> "type=foo && x > 100 & y > 500"
>
> Having a multivalued field for type, x and y doesn't seem to work here as
> I need to maintain the relationship between a type/x/y.
>
> I'm not sure how to approach this problem. Is writing a custom field type
> the
> preferred approach?
>
> thanks,
>
> Phil.
>
>