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 Erick Erickson <er...@gmail.com> on 2014/05/20 18:57:48 UTC

Odd interaction between {!tag..} and {!field}

not  sure what to make of this...
The presence of the {!tag} entry changes the filter query generated by
the {!field...} tag. Note below that in one case the filter query is a
phrase query, and in the other it's parsed with one term against the
specified field and the other against the default field.

Using the example data, submitting this:

http://localhost:8983/solr/collection1/select?q=*:*&fq={!tag=name_name}{!field
f=name}United States&wt=json&indent=true&debug=query

generates this response:
{
  responseHeader:
  {
    status: 0,
    QTime: 10,
    params:
    {
      indent: "true",
      q: "*:*",
      debug: "query",
      wt: "json",
      fq: "{!tag=name_name}{!field f=name}United States"
    }
  },
  response:
  {
    numFound: 0,
    start: 0,
    docs: [ ]
  },
  debug:
  {
    rawquerystring: "*:*",
    querystring: "*:*",
    parsedquery: "MatchAllDocsQuery(*:*)",
    parsedquery_toString: "*:*",
    QParser: "LuceneQParser",
    filter_queries:
    [
      "{!tag=name_name}{!field f=name}United States"
    ],
    parsed_filter_queries:
    [
      "name:united text:states"
    ]
  }
}


while this one:
http://localhost:8983/solr/collection1/select?q=*:*&fq={!field
f=name}United States&wt=json&indent=true&debug=query

gives:
{
  responseHeader:
  {
    status: 0,
    QTime: 3,
    params:
    {
      indent: "true",
      q: "*:*",
      debug: "query",
      wt: "json",
      fq: "{!field f=name}United States"
    }
  },
  response:
  {
    numFound: 0,
    start: 0,
    docs: [ ]
  },
  debug:
  {
    rawquerystring: "*:*",
    querystring: "*:*",
    parsedquery: "MatchAllDocsQuery(*:*)",
    parsedquery_toString: "*:*",
    QParser: "LuceneQParser",
    filter_queries:
    [
      "{!field f=name}United States"
    ],
    parsed_filter_queries:
    [
      "PhraseQuery(name:"united states")"
    ]
  }
}

**** Of course quoting "United States" works. Escaping the space does
NOT change the behavior when {!tag...} is present.

Is this worth a JIRA or am I just missing the obvious?

Erick

Re: Odd interaction between {!tag..} and {!field}

Posted by Erick Erickson <er...@gmail.com>.
Thanks Chris!

The query parsing stuff is something I keep stumbling over, but you
may have noticed that!

Erick

On Tue, May 20, 2014 at 10:06 AM, Chris Hostetter
<ho...@fucit.org> wrote:
>
> : when local params are "embedded" in a query being parsed by the
> : LuceneQParser, it applies them using the same scoping as other query
> : operators....
> :
> : :       fq: "{!tag=name_name}{!field f=name}United States"
>
>
> Think of that example in the context of this one -- the basics of
> when/what/why the variuos pices are parsed are the same...
>
>    fq:  "{!tag=name_name}(+{!field f=name}United text:(States))"
>
>
> -Hoss
> http://www.lucidworks.com/

Re: Odd interaction between {!tag..} and {!field}

Posted by Chris Hostetter <ho...@fucit.org>.
: when local params are "embedded" in a query being parsed by the 
: LuceneQParser, it applies them using the same scoping as other query 
: operators.... 
: 
: :       fq: "{!tag=name_name}{!field f=name}United States"


Think of that example in the context of this one -- the basics of 
when/what/why the variuos pices are parsed are the same...

   fq:  "{!tag=name_name}(+{!field f=name}United text:(States))"


-Hoss
http://www.lucidworks.com/

Re: Odd interaction between {!tag..} and {!field}

Posted by Chris Hostetter <ho...@fucit.org>.
: The presence of the {!tag} entry changes the filter query generated by
: the {!field...} tag. Note below that in one case the filter query is a
: phrase query, and in the other it's parsed with one term against the
: specified field and the other against the default field.

I think you are missunderstanding the way the localparams logic works.

when localparams are at the begining of the param, they apply to the 
entire string value

when local params are "embedded" in a query being parsed by the 
LuceneQParser, it applies them using the same scoping as other query 
operators.... 

:       fq: "{!tag=name_name}{!field f=name}United States"

that says "parse this entire query string using the default parser,, using 
"tag=name_name" on the result.  then he LuceneQParser gets the string 
"{!field f=name}United States" and it parses "United" using the "field" 
Qparser, and "Stats" using itself.

:       fq: "{!field f=name}United States"

that says "parse this entire query string using the "field" parser.

I think what you want is...

        fq: "{!field f=name tag=name_name}United States"

or more explicitly w/o shortcut...

        fq: "{!tag=name_name type=field f=name}United States"


-Hoss
http://www.lucidworks.com/