You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by "Koji Sekiguchi (JIRA)" <ji...@apache.org> on 2009/04/27 19:12:31 UTC

[jira] Issue Comment Edited: (SOLR-64) strict hierarchical facets

    [ https://issues.apache.org/jira/browse/SOLR-64?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12703221#action_12703221 ] 

Koji Sekiguchi edited comment on SOLR-64 at 4/27/09 10:12 AM:
--------------------------------------------------------------

First draft, need more test. This version doesn't support distributed environment.

- schema setup
{code:xml|title=schema.xml}
<fieldType name="hierarchy" class="solr.HierarchicalFacetField" omitNorms="true" positionIncrementGap="0" indexed="true" stored="false" />
<field name="hiefacet" type="hierarchy" indexed="true" stored="true" multiValued="true" />
{code}

- sample data
{code:xml|title=sample data}
<add>
  <doc>
    <field name="id">1</field>
    <field name="hiefacet">A/B/E/</field>
    <field name="hiefacet">B/B/D/E/</field>
  </doc>
  <doc>
    <field name="id">2</field>
    <field name="hiefacet">A/B/E/</field>
  </doc>
  <doc>
    <field name="id">3</field>
    <field name="hiefacet">A/B/F/</field>
  </doc>
  <doc>
    <field name="id">4</field>
    <field name="hiefacet">A/C/G/</field>
  </doc>
  <doc>
    <field name="id">5</field>
    <field name="hiefacet">A/C/G/</field>
  </doc>
  <doc>
    <field name="id">6</field>
    <field name="hiefacet">A/C/G/</field>
  </doc>
  <doc>
    <field name="id">7</field>
    <field name="hiefacet">A/D/</field>
  </doc>
  <doc>
    <field name="id">8</field>
    <field name="hiefacet">A/</field>
  </doc>
  <doc>
    <field name="id">9</field>
    <field name="hiefacet">B/B/C/</field>
  </doc>
</add>
{code}

- usage:
http://localhost:8983/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on&facet=on&facet.field=hiefacet&wt=json
{code:title=&facet=on&facet.field=hiefacet}
 "facet_counts":{
  "facet_queries":{},
  "facet_fields":{
	"hiefacet":[
	 "sub_facets",[
	  "A",8,
	  "path-A","A/",
	  "sub_facets",[
		"B",3,
		"path-B","A/B/",
		"sub_facets",[
		 "E",2,
		 "path-E","A/B/E/",
		 "F",1,
		 "path-F","A/B/F/"],
		"C",3,
		"path-C","A/C/",
		"sub_facets",[
		 "G",3,
		 "path-G","A/C/G/"],
		"D",1,
		"path-D","A/D/"],
	  "B",2,
	  "path-B","B/",
	  "sub_facets",[
		"B",2,
		"path-B","B/B/",
		"sub_facets",[
		 "C",1,
		 "path-C","B/B/C/",
		 "D",1,
		 "path-D","B/B/D/",
		 "sub_facets",[
"E",1,
"path-E","B/B/D/E/"]]]]]},
  "facet_dates":{}}
{code}

- usage: facet.depth
http://localhost:8983/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on&facet=on&facet.field=hiefacet&facet.depth=2&wt=json
{code:title=&facet.field=hiefacet&facet.depth=2}
"facet_counts":{
  "facet_queries":{},
  "facet_fields":{
	"hiefacet":[
	 "sub_facets",[
	  "A",8,
	  "path-A","A/",
	  "sub_facets",[
		"B",3,
		"path-B","A/B/",
		"C",3,
		"path-C","A/C/",
		"D",1,
		"path-D","A/D/"],
	  "B",2,
	  "path-B","B/",
	  "sub_facets",[
		"B",2,
		"path-B","B/B/"]]]},
  "facet_dates":{}}
{code}

- usage: facet.prefix
http://localhost:8983/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on&facet=on&facet.field=hiefacet&wt=json&facet.prefix=A%2FB%2F
{code:title=&facet=on&facet.field=hiefacet&facet.prefix=A/B/}
 "facet_counts":{
  "facet_queries":{},
  "facet_fields":{
	"hiefacet":[
	 "sub_facets",[
	  "B",3,
	  "path-B","A/B/",
	  "sub_facets",[
		"E",2,
		"path-E","A/B/E/",
		"F",1,
		"path-F","A/B/F/"]]]},
  "facet_dates":{}}
{code}


      was (Author: koji):
    First draft, need more test. This version doesn't support distributed environment.

- schema setup
{code:xml|title=schema.xml}
<fieldType name="hierarchy" class="solr.HierarchicalFacetField" omitNorms="true" positionIncrementGap="0" indexed="true" stored="false" />
<field name="hiefacet" type="hierarchy" indexed="true" stored="true" multiValued="true" />
{code}

- sample data
{code:xml|title=sample data}
<add>
  <doc>
    <field name="id">1</field>
    <field name="hiefacet">A/B/E/</field>
    <field name="hiefacet">B/B/D/E/</field>
  </doc>
  <doc>
    <field name="id">2</field>
    <field name="hiefacet">A/B/E/</field>
  </doc>
  <doc>
    <field name="id">3</field>
    <field name="hiefacet">A/B/F/</field>
  </doc>
  <doc>
    <field name="id">4</field>
    <field name="hiefacet">A/C/G/</field>
  </doc>
  <doc>
    <field name="id">5</field>
    <field name="hiefacet">A/C/G/</field>
  </doc>
  <doc>
    <field name="id">6</field>
    <field name="hiefacet">A/C/G/</field>
  </doc>
  <doc>
    <field name="id">7</field>
    <field name="hiefacet">A/D/</field>
  </doc>
  <doc>
    <field name="id">8</field>
    <field name="hiefacet">A/</field>
  </doc>
  <doc>
    <field name="id">9</field>
    <field name="hiefacet">B/B/C/</field>
  </doc>
</add>
{code}

- usage:
http://localhost:8983/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on&facet=on&facet.field=hiefacet&wt=json
{code:json}
 "facet_counts":{
  "facet_queries":{},
  "facet_fields":{
	"hiefacet":[
	 "sub_facets",[
	  "A",8,
	  "path-A","A/",
	  "sub_facets",[
		"B",3,
		"path-B","A/B/",
		"sub_facets",[
		 "E",2,
		 "path-E","A/B/E/",
		 "F",1,
		 "path-F","A/B/F/"],
		"C",3,
		"path-C","A/C/",
		"sub_facets",[
		 "G",3,
		 "path-G","A/C/G/"],
		"D",1,
		"path-D","A/D/"],
	  "B",2,
	  "path-B","B/",
	  "sub_facets",[
		"B",2,
		"path-B","B/B/",
		"sub_facets",[
		 "C",1,
		 "path-C","B/B/C/",
		 "D",1,
		 "path-D","B/B/D/",
		 "sub_facets",[
"E",1,
"path-E","B/B/D/E/"]]]]]},
  "facet_dates":{}}
{code}

- usage: facet.depth
http://localhost:8983/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on&facet=on&facet.field=hiefacet&facet.depth=2&wt=json
{code:json}
"facet_counts":{
  "facet_queries":{},
  "facet_fields":{
	"hiefacet":[
	 "sub_facets",[
	  "A",8,
	  "path-A","A/",
	  "sub_facets",[
		"B",3,
		"path-B","A/B/",
		"C",3,
		"path-C","A/C/",
		"D",1,
		"path-D","A/D/"],
	  "B",2,
	  "path-B","B/",
	  "sub_facets",[
		"B",2,
		"path-B","B/B/"]]]},
  "facet_dates":{}}
{code}

- usage: facet.prefix
http://localhost:8983/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on&facet=on&facet.field=hiefacet&wt=json&facet.prefix=A%2FB%2F
{code:json}
 "facet_counts":{
  "facet_queries":{},
  "facet_fields":{
	"hiefacet":[
	 "sub_facets",[
	  "B",3,
	  "path-B","A/B/",
	  "sub_facets",[
		"E",2,
		"path-E","A/B/E/",
		"F",1,
		"path-F","A/B/F/"]]]},
  "facet_dates":{}}
{code}

  
> strict hierarchical facets
> --------------------------
>
>                 Key: SOLR-64
>                 URL: https://issues.apache.org/jira/browse/SOLR-64
>             Project: Solr
>          Issue Type: New Feature
>          Components: search
>            Reporter: Yonik Seeley
>             Fix For: 1.5
>
>         Attachments: SOLR-64.patch
>
>
> Strict Facet Hierarchies... each tag has at most one parent (a tree).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.