Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nested fields in SOLR

I've got a question about the possibility to create nested fields in solr. Google searches told me something about group but I think its just for the result?

what I want to have is a structure like that:

  • Category1
    • item 1 (9)
    • item 2 (8)
  • Category2
    • item 3 (6)
  • Category3
    • item 4 (23)

I tried something like this:

<field name="Category" type="string" indexed="true" stored="true" multiValued="true" required="false">
<field name="MiscellaneousName" type="string" indexed="true" stored="true" multiValued="true" required="false"/>

But it does not work.

Update: The categories and items should be faceted. Everey item(=facet) is part of a category. One Category could have multiple or null fields. The Categories and items are stored in a database an I want to index them dynamically. I only want to search for the items, the categories are just text. I'm using solr 3.3 with Tomcat 7.

like image 548
HW90 Avatar asked Oct 10 '11 13:10

HW90


2 Answers

Thanks for the update. Pivot facets allow you to do something like:

  • Category1 (17)
    • item 1 (9)
    • item 2 (8)
  • Category2 (6)
    • item 3 (6)
  • Category3 (23)
    • item 4 (23)

.. but they are only available in Solr 4.0 (trunk). You can, however, simulate these results in lower Solr's (down to 1.4), although it is a bit complicated and requires two Solr queries instead of one. I wrote a blog post on this -- Pivot Faceting (Decision Trees) in Solr 1.4.

You can keep the schema you have in your original question -- pivot faceting (real or simulated) works on any arbitrary, different (or same) fields.

like image 150
Ryan Roemer Avatar answered Sep 21 '22 18:09

Ryan Roemer


Pivot facets is what you need to define hierarchy faceting.
However, you would need to use the trunk build to have it working.

If you have issues upgrading, you can check the option @ http://www.lucidimagination.com/why-lucid/webinars/mastering-power-faceted-search

This is a workaround, and needs you to manipulate the data you feed.

Cattegory1 -> item 1  
0//Cattegory1 and 1//Cattegory1//item1

It works with a combination of -
filter results using fq=category:"0//Cattegory1"
facet.prefix which will help you to limit the facets depending on the level, if you need to limit results

Also http://wiki.apache.org/solr/HierarchicalFaceting, might be useful.

like image 40
Jayendra Avatar answered Sep 18 '22 18:09

Jayendra