You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2009/10/25 23:37:51 UTC
[Solr Wiki] Update of "FieldCollapsing" by martijn
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.
The "FieldCollapsing" page has been changed by martijn.
http://wiki.apache.org/solr/FieldCollapsing?action=diff&rev1=5&rev2=6
--------------------------------------------------
= Field Collapsing =
+ /!\ This referes to functionality from [[https://issues.apache.org/jira/browse/SOLR-236|SOLR-236]]]
+ This patch is not complete, but it will be useful to keep this page updated while the interface evolves.
+ From [[http://www.fastsearch.com/glossary.aspx?m=48&amid=299|fast search]]]
+
+ {{{
- /!\ This referes to functionality from [[https://issues.apache.org/jira/browse/SOLR-236|SOLR-236]]]
-
- This patch is not complete, but it will be useful to keep this page updated while the interface evolves.
-
- From [[http://www.fastsearch.com/glossary.aspx?m=48&amid=299|fast search]]]
- {{{
"Used in order to collapse a group of results with similar value for a given field to a single entry in the result set. Site collapsing is a special case of this, where all results for a given web site is collapsed into one or two entries in the result set, typically with an associated "more documents from this site" link. See also Duplicate detection."
+ }}}
- }}}
-
- This topic was discussed a while ago: http://www.nabble.com/result-grouping--tf2910425.html#a8131895
+ This topic was discussed a while ago: http://www.nabble.com/result-grouping--tf2910425.html#a8131895
== Setup ==
+ The easiest way to configure field collapsing is by overriding the query component. This can be achieved by adding the following xml in your solrconfig.xml:
-
- To use field collapsing, you'll first need to install the patch. Then you'll need to edit your solrconfig.xml. First, register the collapse searchComponent like this:
{{{
- <searchComponent name="collapse" class="org.apache.solr.handler.component.CollapseComponent" />
+ <searchComponent name="query" class="org.apache.solr.handler.component.CollapseComponent" />
}}}
+ That is all, now you can have field collapse enabled searches. The CollapseComponents extends from the QueryComponent, so a normal search is still possible.
+ If you wish to use both the QueryComponent and the CollapseComponent along side each other then you need to configure a little bit more in your solrconfig.xml. First, register the collapse searchComponent like this:
+
+ {{{
+ <searchComponent name="collapse" class="org.apache.solr.handler.component.CollapseComponent" />
+ }}}
Then reference that search component in a custom search handler. For example, you could modify the standard request handler to look like this:
{{{
@@ -29, +32 @@
<!-- default values for query parameters -->
<lst name="defaults">
<str name="echoParams">explicit</str>
-
+
</lst>
<arr name="components">
- <str>collapse</str>
+ <str>collapse</str>
- <str>facet</str>
+ <str>facet</str>
- <str>highlight</str>
+ <str>highlight</str>
- <str>debug</str>
+ <str>debug</str>
</arr>
</requestHandler>
}}}
-
Note that we have not included "query" in the list of component; the collapse handler implements query functionality itself.
== Parameters ==
-
-
- || '''param''' || '''description''' ||
+ ||'''param''' ||'''description''' ||
- || collapse.type || normal/adjacent -- does this collapse all fields or just the ones that are next to each other. Defaults to normal ||
+ ||collapse.type ||normal/adjacent -- does this collapse all fields or just the ones that are next to each other. Defaults to normal ||
- || collapse.field || Which field to collapse ||
+ ||collapse.field ||Which field to collapse. If this field is not specified then field collapsing is not enabled and falls back to to the QueryComponent to do a search. ||
- || collapse.facet || before/after -- apply faceting before or after collapsing. Defaults to after ||
+ ||collapse.facet ||before/after -- apply faceting before or after collapsing. Defaults to after ||
- || collapse.max || Deprecated use collapse.threshold instead ||
+ ||collapse.max ||Deprecated use collapse.threshold instead ||
- || collapse.threshold || The number of documents with the same value for collapse.field after which collapsing kicks in ||
+ ||collapse.threshold ||The number of documents with the same value for collapse.field after which collapsing kicks in ||
- || collapse.maxdocs || Maximum number of documents to process during field collapsing ||
+ ||collapse.maxdocs ||Maximum number of documents to process during field collapsing ||
- || collapse.info.doc || Return collapse count for each document? Defaults to true ||
+ ||collapse.info.doc ||Return collapse count for each document? Defaults to true ||
- || collapse.info.count || Return collapse count for each field value? Defaults to true ||
+ ||collapse.info.count ||Return collapse count for each field value? Defaults to true ||
- || collapse.includeCollapsedDocs.fl || Parameter indicating to return the collapsed documents in the response and what fields to return in comma separated manner. A value * indicates that all fields will be returned ||
+ ||collapse.includeCollapsedDocs.fl ||Parameter indicating to return the collapsed documents in the response and what fields to return in comma separated manner. A value * indicates that all fields will be returned ||
- || collapse.debug || wheter to include collapse debug information ||
+ ||collapse.debug ||wheter to include collapse debug information ||
-
+ ||collapse.aggregate ||Execute aggregate functions on the collapsed documents. The parameter expect the functions in the following format: function_name(field_name) [, function_name(field_name]. So for example: sum(stock), avg(weight). Currently there are four functions available: min(...), max(...), sum(...), avg(...). The functionality is available from the patch added at 2009-10-25 10:13 PM. ||
== Examples ==
-
-
Using the example data:
Collapse all documents using 'cat' and 'normal' collapse type:
http://localhost:8983/solr/select/?q=*:*&collapse.field=cat&collapse.threshold=1&collapse.type=normal
+
{{{
<lst name="collapse_counts">
<int name="hard">1</int>
@@ -76, +75 @@
<int name="software">1</int>
</lst>
}}}
+ http://localhost:8983/solr/select/?q=*:*&collapse.field=cat&collapse.threshold=1&collapse.type=adjacent
-
- http://localhost:8983/solr/select/?q=*:*&collapse.field=cat&collapse.threshold=1&collapse.type=adjacent
{{{
<lst name="collapse_counts">
<int name="hard">1</int>