lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nadav Har'El (JIRA)" <>
Subject [jira] Commented: (LUCENE-130) field) ignores it's only parameter
Date Mon, 10 Apr 2006 12:29:05 GMT
    [ ] 

Nadav Har'El commented on LUCENE-130:

toString(field) works very well, if you understand what it does. Perhaps the javadoc isn't
explicit enough on what it does and need to be improved.

To the original poster (from two years ago...), here a short explanation. toString() is meant
to be somewhat like a reverse of QueryParser. When you build a QueryParser, you give it a
"default field" and a string query. Whenever the QueryParser sees a term with no field on
it (say, the word "dog") it uses the default field as the field; If the default field name
given to QueryParser is "content", a query of "dog" is equivalent to searching for "content:dog".
 Now, if you run toString() on that generated query the string you'll get is "content:dog".
This is ugly, because it adds a "content:" (the default field name you gave QueryParser) to
every term in your query. In order to remove this default field name, toString() needs to
know what it is, so you pass it as a parameter. So toString("content") remove that field name,
and leaves only "dog".

Now, down to business: the Javadoc currently says about toString(field):

   "Prints a query to a string, with 'field' as the default field for terms."

I would have changed this to

   "Prints a query to a string, with 'field' assumed to be the default field and ommitted."

(or something like that).

> field) ignores it's only parameter
> ---------------------------------------------------------------------------------
>          Key: LUCENE-130
>          URL:
>      Project: Lucene - Java
>         Type: Bug

>   Components: Search
>     Versions: unspecified
>  Environment: Operating System: All
> Platform: PC
>     Reporter: Mark Orr
>     Assignee: Lucene Developers
>     Priority: Minor
>  Attachments:
> The JavaDoc says:
> "Prints a query to a string, with field as the default field for terms. 
> The representation used is one that is readable by QueryParser (although, if 
> the query was created by the parser, the printed representation may not be 
> exactly what was parsed). "
> But as Far as I can tell it doesn't matter what you pass it. It returns the 
> same thing if you had called toString()

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message