You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Steven White <sw...@gmail.com> on 2015/05/14 13:49:27 UTC

Cannot get "uf" (user fields) to work

Hi Everyone,

I'm trying to utilize "uf" but it doesn't work.  My reading of it per:
https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
is I can use it to limit into which fields a search is performed.  E.g.: If
my index has F1, F2, F3, F4, and I set "uf" to F3, than I should get hits
on F3 only.

Here is my request handler:

  <requestHandler name="/select_group_a" class="solr.SearchHandler">
     <lst name="defaults">
       <str name="echoParams">explicit</str>
       <int name="rows">20</int>
       <str name="defType">edismax</str>
       <str name="qf">F1 F2 F3 F4</str>
       <str name="uf">F3</str>
       <str name="fl">type,id,score</str>
       <str name="wt">xml</str>
       <str name="indent">true</str>
     </lst>
  </requestHandler>

I also tried passing "uf" on the URL and it too didn't work.  I'm getting
hits on terms that are in other fields.

Is my usage of "uf" wrong?

Thanks

Steve

Re: Cannot get "uf" (user fields) to work

Posted by Steven White <sw...@gmail.com>.
Thanks Shawn and all for the insight.  This was very helpful.

Steve

On Thu, May 14, 2015 at 10:19 AM, Shawn Heisey <ap...@elyograg.org> wrote:

> On 5/14/2015 6:33 AM, Steven White wrote:
> > I don't follow.  Can you give me an example on how and when to use "uf"?
>
> The uf parameter controls which fields are allowed in the query string.
> If you have "uf=f1 f2" then "q=f3:foo" won't work the way you would
> expect.  If f3 is in the qf parameter, then it will still be used by the
> parser.
>
> I tried the equivalent of q=f3:foo on my own index with uf set to fields
> that did not include that field.  When a field is disallowed, but used
> in the query, there is no error message.  Instead, the data is
> interpreted as raw input, so that example would work like "q=f3\:foo"
> instead.  The colon becomes part of the actual query text.
>
> Testing shows that uf does *NOT* affect filter queries, only the main
> query.  I think this is because filter queries default to the lucene
> parser, not the parser specified in defType.
>
> Thanks,
> Shawn
>
>

Re: Cannot get "uf" (user fields) to work

Posted by Shawn Heisey <ap...@elyograg.org>.
On 5/14/2015 6:33 AM, Steven White wrote:
> I don't follow.  Can you give me an example on how and when to use "uf"?

The uf parameter controls which fields are allowed in the query string. 
If you have "uf=f1 f2" then "q=f3:foo" won't work the way you would
expect.  If f3 is in the qf parameter, then it will still be used by the
parser.

I tried the equivalent of q=f3:foo on my own index with uf set to fields
that did not include that field.  When a field is disallowed, but used
in the query, there is no error message.  Instead, the data is
interpreted as raw input, so that example would work like "q=f3\:foo"
instead.  The colon becomes part of the actual query text.

Testing shows that uf does *NOT* affect filter queries, only the main
query.  I think this is because filter queries default to the lucene
parser, not the parser specified in defType.

Thanks,
Shawn


Re: Cannot get "uf" (user fields) to work

Posted by Steven White <sw...@gmail.com>.
Hi Jack,

I don't follow.  Can you give me an example on how and when to use "uf"?

Thanks,

Steve

On Thu, May 14, 2015 at 8:15 AM, Jack Krupansky <ja...@gmail.com>
wrote:

> The uf parameter applies to the user query string, the q parameter - the q
> parameter may only references fields from uf in the q string. The qf
> parameter specifies fields to be queried behind the scenes and is not seen
> by the user. The term user refers to the person who is specifying the text
> that goes into the q parameter, not the client app that is forming the
> overall Solr query request.
>
>
> -- Jack Krupansky
>
> On Thu, May 14, 2015 at 7:49 AM, Steven White <sw...@gmail.com>
> wrote:
>
> > Hi Everyone,
> >
> > I'm trying to utilize "uf" but it doesn't work.  My reading of it per:
> >
> >
> https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
> > is I can use it to limit into which fields a search is performed.  E.g.:
> If
> > my index has F1, F2, F3, F4, and I set "uf" to F3, than I should get hits
> > on F3 only.
> >
> > Here is my request handler:
> >
> >   <requestHandler name="/select_group_a" class="solr.SearchHandler">
> >      <lst name="defaults">
> >        <str name="echoParams">explicit</str>
> >        <int name="rows">20</int>
> >        <str name="defType">edismax</str>
> >        <str name="qf">F1 F2 F3 F4</str>
> >        <str name="uf">F3</str>
> >        <str name="fl">type,id,score</str>
> >        <str name="wt">xml</str>
> >        <str name="indent">true</str>
> >      </lst>
> >   </requestHandler>
> >
> > I also tried passing "uf" on the URL and it too didn't work.  I'm getting
> > hits on terms that are in other fields.
> >
> > Is my usage of "uf" wrong?
> >
> > Thanks
> >
> > Steve
> >
>

Re: Cannot get "uf" (user fields) to work

Posted by Jack Krupansky <ja...@gmail.com>.
The uf parameter applies to the user query string, the q parameter - the q
parameter may only references fields from uf in the q string. The qf
parameter specifies fields to be queried behind the scenes and is not seen
by the user. The term user refers to the person who is specifying the text
that goes into the q parameter, not the client app that is forming the
overall Solr query request.


-- Jack Krupansky

On Thu, May 14, 2015 at 7:49 AM, Steven White <sw...@gmail.com> wrote:

> Hi Everyone,
>
> I'm trying to utilize "uf" but it doesn't work.  My reading of it per:
>
> https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
> is I can use it to limit into which fields a search is performed.  E.g.: If
> my index has F1, F2, F3, F4, and I set "uf" to F3, than I should get hits
> on F3 only.
>
> Here is my request handler:
>
>   <requestHandler name="/select_group_a" class="solr.SearchHandler">
>      <lst name="defaults">
>        <str name="echoParams">explicit</str>
>        <int name="rows">20</int>
>        <str name="defType">edismax</str>
>        <str name="qf">F1 F2 F3 F4</str>
>        <str name="uf">F3</str>
>        <str name="fl">type,id,score</str>
>        <str name="wt">xml</str>
>        <str name="indent">true</str>
>      </lst>
>   </requestHandler>
>
> I also tried passing "uf" on the URL and it too didn't work.  I'm getting
> hits on terms that are in other fields.
>
> Is my usage of "uf" wrong?
>
> Thanks
>
> Steve
>

Re: Cannot get "uf" (user fields) to work

Posted by Emir Arnautovic <em...@sematext.com>.
Steve,
Your config should be like:

<requestHandler name="/select_group_a" class="solr.SearchHandler">
        <lst name="defaults">
          <str name="echoParams">explicit</str>
          <int name="rows">20</int>
          <str name="defType">edismax</str>
          <str name="qf">F3</str>
          <str name="fl">type,id,score</str>
          <str name="wt">xml</str>
          <str name="indent">true</str>
        </lst>
     </requestHandler>

This means when you query with "something" it will be equivalent to F3:something if you use standard parser. If you specify uf, than it will allow query to contain that field i.e. even you said in qf=F1 F2 F3, if you have in uf=F1, you will be able to define q=F1:something and it will search only F1. Otherwise it will not - did not use it so not sure if it will throw parsing error or will threat "F1:something" as query and search it in F1, F2 and F3.

Thanks,
Emir



On 14.05.2015 14:37, Steven White wrote:
> Hi Emir,
>
> Like I replied to Jack, I don't get it.  I need to see some concrete
> examples.
>
> Thanks
>
> Steve
>
> On Thu, May 14, 2015 at 8:30 AM, Emir Arnautovic <
> emir.arnautovic@sematext.com> wrote:
>
>> Hi Steve,
>> No - you should use qf to limit search to fields you want. If you do not
>> plan to allow users to explicitly state fields they want to search, you
>> don't have to use uf parameter. So, drop uf, and set qf to F3.
>>
>> Thanks,
>> Emir
>>
>>
>> On 14.05.2015 14:09, Steven White wrote:
>>
>>> Hi Emir,
>>>
>>> Are you saying I should remove "qf" if I want to use "uf"?  I just tried
>>> that and got exception:
>>>
>>> java.lang.RuntimeException at
>>>
>>> org.apache.solr.search.ExtendedDismaxQParser$ExtendedDismaxConfiguration.<init>(ExtendedDismaxQParser.java:1497)
>>> at
>>>
>>> org.apache.solr.search.ExtendedDismaxQParser.createConfiguration(ExtendedDismaxQParser.java:270)
>>> at
>>>
>>> org.apache.solr.search.ExtendedDismaxQParser.<init>(ExtendedDismaxQParser.java:132)
>>> at
>>>
>>> org.apache.solr.search.ExtendedDismaxQParserPlugin.createParser(ExtendedDismaxQParserPlugin.java:37)
>>> at org.apache.solr.search.QParser.getParser(QParser.java:315) at
>>>
>>> org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:156)
>>> at
>>>
>>> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:196)
>>> at
>>>
>>> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
>>> at org.apache.solr.core.SolrCore.execute(SolrCore.java:1984) at
>>>
>>> Thanks
>>>
>>> Steve
>>>
>>> On Thu, May 14, 2015 at 8:00 AM, Emir Arnautovic <
>>> emir.arnautovic@sematext.com> wrote:
>>>
>>>   Hi Steve,
>>>> You use qf to limit search on some fields.
>>>>
>>>> Thanks,
>>>> Emir
>>>>
>>>>
>>>> On 14.05.2015 13:49, Steven White wrote:
>>>>
>>>>   Hi Everyone,
>>>>> I'm trying to utilize "uf" but it doesn't work.  My reading of it per:
>>>>>
>>>>>
>>>>> https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
>>>>> is I can use it to limit into which fields a search is performed.  E.g.:
>>>>> If
>>>>> my index has F1, F2, F3, F4, and I set "uf" to F3, than I should get
>>>>> hits
>>>>> on F3 only.
>>>>>
>>>>> Here is my request handler:
>>>>>
>>>>>      <requestHandler name="/select_group_a" class="solr.SearchHandler">
>>>>>         <lst name="defaults">
>>>>>           <str name="echoParams">explicit</str>
>>>>>           <int name="rows">20</int>
>>>>>           <str name="defType">edismax</str>
>>>>>           <str name="qf">F1 F2 F3 F4</str>
>>>>>           <str name="uf">F3</str>
>>>>>           <str name="fl">type,id,score</str>
>>>>>           <str name="wt">xml</str>
>>>>>           <str name="indent">true</str>
>>>>>         </lst>
>>>>>      </requestHandler>
>>>>>
>>>>> I also tried passing "uf" on the URL and it too didn't work.  I'm
>>>>> getting
>>>>> hits on terms that are in other fields.
>>>>>
>>>>> Is my usage of "uf" wrong?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Steve
>>>>>
>>>>>
>>>>>   --
>>>> Monitoring * Alerting * Anomaly Detection * Centralized Log Management
>>>> Solr & Elasticsearch Support * http://sematext.com/
>>>>
>>>>
>>>>
>> --
>> Monitoring * Alerting * Anomaly Detection * Centralized Log Management
>> Solr & Elasticsearch Support * http://sematext.com/
>>
>>

-- 
Monitoring * Alerting * Anomaly Detection * Centralized Log Management
Solr & Elasticsearch Support * http://sematext.com/


Re: Cannot get "uf" (user fields) to work

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
One example:

https://github.com/arafalov/solr-indexing-book/blob/master/published/languages/conf/solrconfig.xml#L36

This is from my book:
https://www.packtpub.com/big-data-and-business-intelligence/instant-apache-solr-indexing-data-how-instant

But I am not sure if it affects the specific concern you have,
hopefully other emails will.

Regards,
   Alex.

----
Solr Analyzers, Tokenizers, Filters, URPs and even a newsletter:
http://www.solr-start.com/

On 14 May 2015 at 22:37, Steven White <sw...@gmail.com> wrote:
> Hi Emir,
>
> Like I replied to Jack, I don't get it.  I need to see some concrete
> examples.
>
> Thanks
>
> Steve

Re: Cannot get "uf" (user fields) to work

Posted by Steven White <sw...@gmail.com>.
Hi Emir,

Like I replied to Jack, I don't get it.  I need to see some concrete
examples.

Thanks

Steve

On Thu, May 14, 2015 at 8:30 AM, Emir Arnautovic <
emir.arnautovic@sematext.com> wrote:

> Hi Steve,
> No - you should use qf to limit search to fields you want. If you do not
> plan to allow users to explicitly state fields they want to search, you
> don't have to use uf parameter. So, drop uf, and set qf to F3.
>
> Thanks,
> Emir
>
>
> On 14.05.2015 14:09, Steven White wrote:
>
>> Hi Emir,
>>
>> Are you saying I should remove "qf" if I want to use "uf"?  I just tried
>> that and got exception:
>>
>> java.lang.RuntimeException at
>>
>> org.apache.solr.search.ExtendedDismaxQParser$ExtendedDismaxConfiguration.<init>(ExtendedDismaxQParser.java:1497)
>> at
>>
>> org.apache.solr.search.ExtendedDismaxQParser.createConfiguration(ExtendedDismaxQParser.java:270)
>> at
>>
>> org.apache.solr.search.ExtendedDismaxQParser.<init>(ExtendedDismaxQParser.java:132)
>> at
>>
>> org.apache.solr.search.ExtendedDismaxQParserPlugin.createParser(ExtendedDismaxQParserPlugin.java:37)
>> at org.apache.solr.search.QParser.getParser(QParser.java:315) at
>>
>> org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:156)
>> at
>>
>> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:196)
>> at
>>
>> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
>> at org.apache.solr.core.SolrCore.execute(SolrCore.java:1984) at
>>
>> Thanks
>>
>> Steve
>>
>> On Thu, May 14, 2015 at 8:00 AM, Emir Arnautovic <
>> emir.arnautovic@sematext.com> wrote:
>>
>>  Hi Steve,
>>> You use qf to limit search on some fields.
>>>
>>> Thanks,
>>> Emir
>>>
>>>
>>> On 14.05.2015 13:49, Steven White wrote:
>>>
>>>  Hi Everyone,
>>>>
>>>> I'm trying to utilize "uf" but it doesn't work.  My reading of it per:
>>>>
>>>>
>>>> https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
>>>> is I can use it to limit into which fields a search is performed.  E.g.:
>>>> If
>>>> my index has F1, F2, F3, F4, and I set "uf" to F3, than I should get
>>>> hits
>>>> on F3 only.
>>>>
>>>> Here is my request handler:
>>>>
>>>>     <requestHandler name="/select_group_a" class="solr.SearchHandler">
>>>>        <lst name="defaults">
>>>>          <str name="echoParams">explicit</str>
>>>>          <int name="rows">20</int>
>>>>          <str name="defType">edismax</str>
>>>>          <str name="qf">F1 F2 F3 F4</str>
>>>>          <str name="uf">F3</str>
>>>>          <str name="fl">type,id,score</str>
>>>>          <str name="wt">xml</str>
>>>>          <str name="indent">true</str>
>>>>        </lst>
>>>>     </requestHandler>
>>>>
>>>> I also tried passing "uf" on the URL and it too didn't work.  I'm
>>>> getting
>>>> hits on terms that are in other fields.
>>>>
>>>> Is my usage of "uf" wrong?
>>>>
>>>> Thanks
>>>>
>>>> Steve
>>>>
>>>>
>>>>  --
>>> Monitoring * Alerting * Anomaly Detection * Centralized Log Management
>>> Solr & Elasticsearch Support * http://sematext.com/
>>>
>>>
>>>
> --
> Monitoring * Alerting * Anomaly Detection * Centralized Log Management
> Solr & Elasticsearch Support * http://sematext.com/
>
>

Re: Cannot get "uf" (user fields) to work

Posted by Emir Arnautovic <em...@sematext.com>.
Hi Steve,
No - you should use qf to limit search to fields you want. If you do not 
plan to allow users to explicitly state fields they want to search, you 
don't have to use uf parameter. So, drop uf, and set qf to F3.

Thanks,
Emir

On 14.05.2015 14:09, Steven White wrote:
> Hi Emir,
>
> Are you saying I should remove "qf" if I want to use "uf"?  I just tried
> that and got exception:
>
> java.lang.RuntimeException at
> org.apache.solr.search.ExtendedDismaxQParser$ExtendedDismaxConfiguration.<init>(ExtendedDismaxQParser.java:1497)
> at
> org.apache.solr.search.ExtendedDismaxQParser.createConfiguration(ExtendedDismaxQParser.java:270)
> at
> org.apache.solr.search.ExtendedDismaxQParser.<init>(ExtendedDismaxQParser.java:132)
> at
> org.apache.solr.search.ExtendedDismaxQParserPlugin.createParser(ExtendedDismaxQParserPlugin.java:37)
> at org.apache.solr.search.QParser.getParser(QParser.java:315) at
> org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:156)
> at
> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:196)
> at
> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
> at org.apache.solr.core.SolrCore.execute(SolrCore.java:1984) at
>
> Thanks
>
> Steve
>
> On Thu, May 14, 2015 at 8:00 AM, Emir Arnautovic <
> emir.arnautovic@sematext.com> wrote:
>
>> Hi Steve,
>> You use qf to limit search on some fields.
>>
>> Thanks,
>> Emir
>>
>>
>> On 14.05.2015 13:49, Steven White wrote:
>>
>>> Hi Everyone,
>>>
>>> I'm trying to utilize "uf" but it doesn't work.  My reading of it per:
>>>
>>> https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
>>> is I can use it to limit into which fields a search is performed.  E.g.:
>>> If
>>> my index has F1, F2, F3, F4, and I set "uf" to F3, than I should get hits
>>> on F3 only.
>>>
>>> Here is my request handler:
>>>
>>>     <requestHandler name="/select_group_a" class="solr.SearchHandler">
>>>        <lst name="defaults">
>>>          <str name="echoParams">explicit</str>
>>>          <int name="rows">20</int>
>>>          <str name="defType">edismax</str>
>>>          <str name="qf">F1 F2 F3 F4</str>
>>>          <str name="uf">F3</str>
>>>          <str name="fl">type,id,score</str>
>>>          <str name="wt">xml</str>
>>>          <str name="indent">true</str>
>>>        </lst>
>>>     </requestHandler>
>>>
>>> I also tried passing "uf" on the URL and it too didn't work.  I'm getting
>>> hits on terms that are in other fields.
>>>
>>> Is my usage of "uf" wrong?
>>>
>>> Thanks
>>>
>>> Steve
>>>
>>>
>> --
>> Monitoring * Alerting * Anomaly Detection * Centralized Log Management
>> Solr & Elasticsearch Support * http://sematext.com/
>>
>>

-- 
Monitoring * Alerting * Anomaly Detection * Centralized Log Management
Solr & Elasticsearch Support * http://sematext.com/


Re: Cannot get "uf" (user fields) to work

Posted by Steven White <sw...@gmail.com>.
Hi Emir,

Are you saying I should remove "qf" if I want to use "uf"?  I just tried
that and got exception:

java.lang.RuntimeException at
org.apache.solr.search.ExtendedDismaxQParser$ExtendedDismaxConfiguration.<init>(ExtendedDismaxQParser.java:1497)
at
org.apache.solr.search.ExtendedDismaxQParser.createConfiguration(ExtendedDismaxQParser.java:270)
at
org.apache.solr.search.ExtendedDismaxQParser.<init>(ExtendedDismaxQParser.java:132)
at
org.apache.solr.search.ExtendedDismaxQParserPlugin.createParser(ExtendedDismaxQParserPlugin.java:37)
at org.apache.solr.search.QParser.getParser(QParser.java:315) at
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:156)
at
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:196)
at
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1984) at

Thanks

Steve

On Thu, May 14, 2015 at 8:00 AM, Emir Arnautovic <
emir.arnautovic@sematext.com> wrote:

> Hi Steve,
> You use qf to limit search on some fields.
>
> Thanks,
> Emir
>
>
> On 14.05.2015 13:49, Steven White wrote:
>
>> Hi Everyone,
>>
>> I'm trying to utilize "uf" but it doesn't work.  My reading of it per:
>>
>> https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
>> is I can use it to limit into which fields a search is performed.  E.g.:
>> If
>> my index has F1, F2, F3, F4, and I set "uf" to F3, than I should get hits
>> on F3 only.
>>
>> Here is my request handler:
>>
>>    <requestHandler name="/select_group_a" class="solr.SearchHandler">
>>       <lst name="defaults">
>>         <str name="echoParams">explicit</str>
>>         <int name="rows">20</int>
>>         <str name="defType">edismax</str>
>>         <str name="qf">F1 F2 F3 F4</str>
>>         <str name="uf">F3</str>
>>         <str name="fl">type,id,score</str>
>>         <str name="wt">xml</str>
>>         <str name="indent">true</str>
>>       </lst>
>>    </requestHandler>
>>
>> I also tried passing "uf" on the URL and it too didn't work.  I'm getting
>> hits on terms that are in other fields.
>>
>> Is my usage of "uf" wrong?
>>
>> Thanks
>>
>> Steve
>>
>>
> --
> Monitoring * Alerting * Anomaly Detection * Centralized Log Management
> Solr & Elasticsearch Support * http://sematext.com/
>
>

Re: Cannot get "uf" (user fields) to work

Posted by Emir Arnautovic <em...@sematext.com>.
Hi Steve,
You use qf to limit search on some fields.

Thanks,
Emir

On 14.05.2015 13:49, Steven White wrote:
> Hi Everyone,
>
> I'm trying to utilize "uf" but it doesn't work.  My reading of it per:
> https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
> is I can use it to limit into which fields a search is performed.  E.g.: If
> my index has F1, F2, F3, F4, and I set "uf" to F3, than I should get hits
> on F3 only.
>
> Here is my request handler:
>
>    <requestHandler name="/select_group_a" class="solr.SearchHandler">
>       <lst name="defaults">
>         <str name="echoParams">explicit</str>
>         <int name="rows">20</int>
>         <str name="defType">edismax</str>
>         <str name="qf">F1 F2 F3 F4</str>
>         <str name="uf">F3</str>
>         <str name="fl">type,id,score</str>
>         <str name="wt">xml</str>
>         <str name="indent">true</str>
>       </lst>
>    </requestHandler>
>
> I also tried passing "uf" on the URL and it too didn't work.  I'm getting
> hits on terms that are in other fields.
>
> Is my usage of "uf" wrong?
>
> Thanks
>
> Steve
>

-- 
Monitoring * Alerting * Anomaly Detection * Centralized Log Management
Solr & Elasticsearch Support * http://sematext.com/