Skip to content

Apache Lucene open-source search software

SOLR-9685: documenting #tags in query DSL.

Mikhail Khludnev052fede51d63
diff --git a/solr/solr-ref-guide/src/json-facet-api.adoc b/solr/solr-ref-guide/src/json-facet-api.adoc
index 183f940d1d1..a7766b22ab1 100644
--- a/solr/solr-ref-guide/src/json-facet-api.adoc
+++ b/solr/solr-ref-guide/src/json-facet-api.adoc
@@ -320,6 +320,27 @@ The value of `filter` can be a single query to treat as a filter, or a list of f
* a string containing a query in Solr query syntax
* a reference to a request parameter containing Solr query syntax, of the form: `{param : <request_param_name>}`
+== Filter Exclusions
+One can exclude top-level filters and query *before* faceting via the `excludeTags` keywords in the `domain` block of the facet.
+
+Example:
+[source,bash]
+----
+&q={!tag=top}"running shorts"
+&fq={!tag=COLOR}color:Blue
+&json={
+ filter:"{!tag=BRAND}brand:Bosco"
+ facet:{
+ sizes:{type:terms, field:size},
+ colors:{type:terms, field:color, domain:{excludeTags:COLOR} },
+ brands:{type:terms, field:brand, domain:{excludeTags:"BRAND,top"} }
+ }
+}
+----
+
+The value of `excludeTags` can be a single string tag, array of string tags or comma-separated tags in the single string.
+See also the section on <<faceting.adoc#tagging-and-excluding-filters,multi-select faceting>>.
+
== Aggregation Functions
Aggregation functions, also called *facet functions, analytic functions,* or **metrics**, calculate something interesting over a domain (each facet bucket).
diff --git a/solr/solr-ref-guide/src/json-query-dsl.adoc b/solr/solr-ref-guide/src/json-query-dsl.adoc
index 58d2baa45c2..9c9ba645ee8 100644
--- a/solr/solr-ref-guide/src/json-query-dsl.adoc
+++ b/solr/solr-ref-guide/src/json-query-dsl.adoc
@@ -168,3 +168,20 @@ curl -XGET http://localhost:8983/solr/books/query -d '
{ "lucene" : {"df: "content", query : "lucene solr" }}
]
}'
+
+== Tagging in JSON Query DSL
+Queries and filters might be tagged by inserting JSON object with the single property with name starting with a hash (`#`). Tags can be applied to the single string syntax and to a full JSON object query as well:
+
+[source,bash]
+curl -XGET http://localhost:8983/solr/books/query -d '
+{
+ "filter: [ // this applies `titletag`
+ {"#titletag": "title:solr"},
+ { // this applies `tagcontent`
+ "#tagcontent":
+ {"lucene": {"df:"content", query :"lucene solr"}}
+ }
+ ]
+}'
+
+There might be many comma separated tags like `{"#title,tag2,tag3":"title:solr"}`. Tags can be used in <<faceting.adoc#tagging-and-excluding-filters,old facets>> and in <<json-facet-api.adoc#filter-exclusions,JSON Facets'>> `excludeTags` as well. Notice that the leading hash requires to use double quotes as in regular JSON.