Thank you Alessandro for the suggestion (i have to investigate about solrJ), 
and thank you Mikhail for the explanation.
My problem isn’t related to that simple query and it don't depends on framework 
java.
Maybe i’m not smart enough, but if i have this query:

WHERE (macro_category = DRINKS AND micro_category = WATER) OR 
macro_catogory=FOODS

where i say:”i want drinks that are only water and also all the foods”, i don’t 
understand how to make this with separated fq for fields.Obviously this:

fq={!tag=MACRO}macrocategory:(DRINKS FOOD)&fq={!tag=MICRO}microcategory:WATER

doesn’t work.

Thanks,
Filippo


> On 18 Feb 2016, at 15:47, Alessandro Benedetti <abenede...@apache.org> wrote:
> 
> As Mikhail suggests, are you sure spring data solr is the right tool for
> you ?
> Probably is a great tool for a newbie ( to be honest I just noticed it
> right now) but maybe you need a more customisable approach to build
> tag/exclusion filter queries on top of facets.
> You could use spring data but then using solrJ for customised approaches.
> 
> Cheers
> 
> On 18 February 2016 at 13:41, Mikhail Khludnev <mkhlud...@griddynamics.com>
> wrote:
> 
>> Tagging works only in the way I describe. Otherwise you might need to need
>> issue separate queries.
>> However, are you sure that this case shouldn't be done in more regular way:
>> fq={!tag=foo}department:foods&fq={!tag=foo}macro_category.key:(drinks food)
>> 
>> On Thu, Feb 18, 2016 at 1:48 PM, Filippo La Torre <
>> filippo.lato...@stentle.com> wrote:
>> 
>>> Hi,
>>> thank for your response.
>>> The problem is that i make this query by Spring Data Solr and i have to
>>> make complex  AND/OR.
>>> Example :
>>> 
>>> ( department:foods AND macro_category.key:drinks) OR ( department:foods
>>> AND macro_category.key:food)
>>> 
>>> What is the best practice the make complex AND/OR query and tagging?
>>> 
>>> Thanks,
>>> Filippo
>>>> On 18 Feb 2016, at 11:19, Mikhail Khludnev <mkhlud...@griddynamics.com
>>> 
>>> wrote:
>>>> 
>>>> just do
>>>> 
>>> 
>> fq={!tag=DEPARTMENT}department:foods&fq={!tag=MACROCATEGORY}macro_category.key:drinks
>>>> tagging in the middle of the query may somehow work, but it's not a
>>>> recommended way.
>>>> 
>>>> On Thu, Feb 18, 2016 at 11:48 AM, Filippo La Torre <
>>>> filippo.lato...@stentle.com> wrote:
>>>> 
>>>>> Hello everyone,
>>>>> 
>>>>> this is my first mail to solr user mailing list.
>>>>> I’m new to Solr too, my Solr version is 5.4.1.
>>>>> I have a problem with filter query and faceting, i have to make a
>> filter
>>>>> query with AND/OR using also faceting (i will make this query using
>>> Spring
>>>>> Data Solr).
>>>>> It seems that the same filter query with brackets and without brackets
>>>>> give different result. The version with brackets don’t see
>> tag/exclude.
>>> How
>>>>> it is possible?
>>>>> 
>>>>> Best regards.
>>>>> 
>>>>> With brackets:
>>>>> 
>>>>> {
>>>>> "responseHeader": {
>>>>>   "status": 0,
>>>>>   "QTime": 2,
>>>>>   "params": {
>>>>>     "q": "*:*",
>>>>>     "facet.field":
>> "{!ex=DEPARTMENT,MACROCATEGORY}macro_category.key",
>>>>>     "indent": "true",
>>>>>     "fq": "({!tag=DEPARTMENT}department:foods AND
>>>>> {!tag=MACROCATEGORY}macro_category.key:drinks)",
>>>>>     "wt": "json",
>>>>>     "facet": "true",
>>>>>     "_": "1455700122431"
>>>>>   }
>>>>> },
>>>>> "response": {
>>>>>   "numFound": 1,
>>>>>   "start": 0,
>>>>>   "docs": [
>>>>>     {
>>>>>       "id": "5672a222fa4d0e4c0d965cc5",
>>>>>       "published": true,
>>>>>       "micro_category.key": "drinks-beer",
>>>>>       "department": "foods",
>>>>>       "macro_category.key": "drinks",
>>>>>       "retail_price": 1,
>>>>>       "selling_price": 1
>>>>>     }
>>>>>   ]
>>>>> },
>>>>> "facet_counts": {
>>>>>   "facet_queries": {},
>>>>>   "facet_fields": {
>>>>>     "macro_category.key": [
>>>>>       "drinks",
>>>>>       1,
>>>>>       "box-collection",
>>>>>       0
>>>>>     ]
>>>>>   },
>>>>>   "facet_dates": {},
>>>>>   "facet_ranges": {},
>>>>>   "facet_intervals": {},
>>>>>   "facet_heatmaps": {}
>>>>> }
>>>>> }
>>>>> 
>>>>> Without brackets:
>>>>> 
>>>>> {
>>>>> "responseHeader": {
>>>>>   "status": 0,
>>>>>   "QTime": 1,
>>>>>   "params": {
>>>>>     "q": "*:*",
>>>>>     "facet.field":
>> "{!ex=DEPARTMENT,MACROCATEGORY}macro_category.key",
>>>>>     "indent": "true",
>>>>>     "fq": "{!tag=DEPARTMENT}department:foods AND
>>>>> {!tag=MACROCATEGORY}macro_category.key:drinks",
>>>>>     "wt": "json",
>>>>>     "facet": "true",
>>>>>     "_": "1455702347556"
>>>>>   }
>>>>> },
>>>>> "response": {
>>>>>   "numFound": 1,
>>>>>   "start": 0,
>>>>>   "docs": [
>>>>>     {
>>>>>       "id": "5672a222fa4d0e4c0d965cc5",
>>>>>       "published": true,
>>>>>       "micro_category.key": "drinks-beer",
>>>>>       "department": "foods",
>>>>>       "macro_category.key": "drinks",
>>>>>       "retail_price": 1,
>>>>>       "selling_price": 1
>>>>>     }
>>>>>   ]
>>>>> },
>>>>> "facet_counts": {
>>>>>   "facet_queries": {},
>>>>>   "facet_fields": {
>>>>>     "macro_category.key": [
>>>>>       "box-collection",
>>>>>       2,
>>>>>       "drinks",
>>>>>       1
>>>>>     ]
>>>>>   },
>>>>>   "facet_dates": {},
>>>>>   "facet_ranges": {},
>>>>>   "facet_intervals": {},
>>>>>   "facet_heatmaps": {}
>>>>> }
>>>>> }
>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> Sincerely yours
>>>> Mikhail Khludnev
>>>> Principal Engineer,
>>>> Grid Dynamics
>>>> 
>>>> <http://www.griddynamics.com>
>>>> <mkhlud...@griddynamics.com>
>>> 
>>> 
>> 
>> 
>> --
>> Sincerely yours
>> Mikhail Khludnev
>> Principal Engineer,
>> Grid Dynamics
>> 
>> <http://www.griddynamics.com>
>> <mkhlud...@griddynamics.com>
>> 
> 
> 
> 
> -- 
> --------------------------
> 
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
> 
> "Tyger, tyger burning bright
> In the forests of the night,
> What immortal hand or eye
> Could frame thy fearful symmetry?"
> 
> William Blake - Songs of Experience -1794 England

Reply via email to