7

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.

javanna
  • 59,145
  • 14
  • 144
  • 125
HW90
  • 1,953
  • 2
  • 21
  • 45
  • Which Solr are you using? If 4.0, it looks like you are looking for [pivot facets](http://wiki.apache.org/solr/SimpleFacetParameters#Pivot_.28ie_Decision_Tree.29_Faceting). If so, here's a good [introductory article](http://solr.pl/en/2010/10/25/hierarchical-faceting-pivot-facets-in-trunk/). – Ryan Roemer Oct 10 '11 at 15:18

3 Answers3

6

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.

Ryan Roemer
  • 987
  • 7
  • 13
  • Thanks for your answer! It looks like the thing I need! Do you think solr 4.0 is ready to use? And where to get? – HW90 Oct 10 '11 at 16:09
  • "Solr 4.0" really means current Solr trunk, which you'll have to look into on your own to see if it is stable in the area's you will use -- there's a lot of new stuff in the release in various states of "done". At work, we run 1.4.1, and it's solid as a rock, but we haven't taken a leap yet. If you don't know for sure, your best off going with stable (Solr 3.4), and using the two-query technique I outline in my blog post -- it is nowhere near as easy as real pivot facets in 4.0, but both will get you the tree of facets you seek... – Ryan Roemer Oct 10 '11 at 18:00
1

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.

Jayendra
  • 52,349
  • 4
  • 80
  • 90
  • thanks for your answer, I've updated my question. But how to make the Cattegory a part of the item? If this would be possible I could group them on client site... – HW90 Oct 10 '11 at 15:06
0

Could you make the category just a field of the item, so that e.g. when you search category 1 item 1 and 2 come back in the results?

If you have two fields that absolutely have to be part of an entity and have to be associated with each other, poly fields might help. They were designed for things like a point that has an x and y value.

I think we need to know more about what exactly you are trying to do to suggest good ways to handle it in Solr.

tedders
  • 1,012
  • 2
  • 11
  • 22
  • thanks for your answer, I've updated my question. I wont search for the cattegories, just for the items. But how to make the cattegory part of the item? – HW90 Oct 10 '11 at 15:08
  • Make the entities that you add items, and have one field in the item be 'category'. Fill this in with the category. Sorry, tried to add an example but having a terrible time with formatting. EDIT: After your update, I think this is not what you need. Good luck finding your real answer! – tedders Oct 10 '11 at 15:40