Special characters in SOLR queries ( q and fq ) must be escaped if you need to search for them literally, otherwise queryParser will take on their special meaning. (See "Resetting Special Characters" in the SOLR Documentation
In the + example, the character is not escaped in fq :
{!tag=f_Memory\(GB\)}f_Memory\(GB\):4+GB
These screening rules do not apply to local parameters , i.e. all between {! and } .
In this example, you escaped ( and ) in the tag label. Thus, the label defined as {!tag=f_Memory\(GB\)} in the filter differs from the label specified in {!ex=f_Memory+(GB)} in the face field, so the filter is not excluded during cutting, and for face creation uses only relevant documents.
You should write a filter like:
{!tag=f_Memory(GB)}f_Memory\(GB\):4\+GB
and facet like
{!ex=f_Memory+(GB)}f_Memory+(GB)
to get what you are looking for.
An example of a complete valid query:
../select?indent=on&wt=json&facet.field={!ex%3Df_Memory(GB)}f_Memory(GB)&fq={!tag%3Df_Memory(GB)}f_Memory\(GB\):4\%2BGB&q=CategoryID:(1+OR+2+OR+3+OR+4)&start=0&rows=10&defType=edismax&facet.mincount=1&facet=true&spellcheck.collate=true
A simple real example that I tested locally:
This is the data in the kernel:
Request:
http://localhost:8983/solr/test/select?q=*%3A*&fl=id%2Cf_*%2Cpa_*&wt=json&indent=true
Answer:
{ "responseHeader": { "status": 0, "QTime": 1, "params": { "q": "*:*", "indent": "true", "fl": "id,f_*,pa_*", "wt": "json", "_": "1474529614808" } }, "response": { "numFound": 2, "start": 0, "docs": [ { "id": "1", "f_Memory(GB)": [ "4+GB" ], "pa_RAM(GB)": [ "2+GB", "4GB", "8GB" ] }, { "id": "2", "f_Memory(GB)": [ "8+GB" ], "pa_RAM(GB)": [ "4GB" ] } ] } }
Work cut:
Request:
http://localhost:8983/solr/test/select?q=*%3A*&fq=%7B!tag%3Df_Memory(GB)%7Df_Memory%5C(GB%5C)%3A4%5C%2BGB&fl=id%2Cf_*%2Cpa_*&wt=json&indent=true&facet=true&facet.field=%7B!ex%3Df_Memory(GB)%7Df_Memory(GB)
Answer:
{ "responseHeader": { "status": 0, "QTime": 2, "params": { "q": "*:*", "facet.field": "{!ex=f_Memory(GB)}f_Memory(GB)", "indent": "true", "fl": "id,f_*,pa_*", "fq": "{!tag=f_Memory(GB)}f_Memory\\(GB\\):4\\+GB", "wt": "json", "facet": "true", "_": "1474530054207" } }, "response": { "numFound": 1, "start": 0, "docs": [ { "id": "1", "f_Memory(GB)": [ "4+GB" ], "pa_RAM(GB)": [ "2+GB", "4GB", "8GB" ] } ] }, "facet_counts": { "facet_queries": {}, "facet_fields": { "f_Memory(GB)": [ "4+GB", 1, "8+GB", 1 ] }, "facet_dates": {}, "facet_ranges": {}, "facet_intervals": {}, "facet_heatmaps": {} } }