You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by addman <ad...@yahoo.com> on 2009/04/08 17:45:26 UTC
Query any data
Hi,
Is it possible to create a query to search a field for any value? I just
need to know if the optional field contain any data at all.
--
View this message in context: http://www.nabble.com/Query-any-data-tp22953431p22953431.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Query any data
Posted by Tim Williams <wi...@gmail.com>.
2009/4/10 Matthew Hall <mh...@informatics.jax.org>:
> I think I would tackle this in a slightly different manner.
>
> When you are creating this index, make sure that that field has a
> default value. Make sure this value is something that could never appear
> in the index otherwise. Then, when you goto place this field into the
> index, either write out your actual value, or the default one.
>
> Then when you get the document back, you can look at that field, and
> solve your question. You can also craft queries that specifically avoid
> entries that don't have a value in this field with a not clause.
I think this is limited by...
... not being able to [easily] add new fields over time... you'd have
to reindex all documents (to insert the new magic token) just to add a
new field.
... requiring additional manipulation for appendable, updateable
fields... when you append new data to a field, you'd have to go in and
remove the special token.
--tim
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Query any data
Posted by Matthew Hall <mh...@informatics.jax.org>.
I think I would tackle this in a slightly different manner.
When you are creating this index, make sure that that field has a
default value. Make sure this value is something that could never appear
in the index otherwise. Then, when you goto place this field into the
index, either write out your actual value, or the default one.
Then when you get the document back, you can look at that field, and
solve your question. You can also craft queries that specifically avoid
entries that don't have a value in this field with a not clause.
Hope this helps,
Matt
Erick Erickson wrote:
> searching for fieldname:* will be *extremely* expensive as it will, by
> default,
> build a giant OR clause consisting of every term in the field. You'll throw
> MaxClauses exceptions right and left. I'd follow Tim's thread lead first....
>
> Best
> Erick
>
> 2009/4/8 王巍巍 <ww...@gmail.com>
>
>
>> first you should change your querypaser to accept wildcard query by calling
>> method of QueryParser
>> setAllowLeadingWildcard
>> then you can query like this: fieldname:*
>>
>> 2009/4/9 Tim Williams <wi...@gmail.com>
>>
>>
>>> On Wed, Apr 8, 2009 at 11:45 AM, addman <ad...@yahoo.com> wrote:
>>>
>>>> Hi,
>>>> Is it possible to create a query to search a field for any value? I
>>>>
>>> just
>>>
>>>> need to know if the optional field contain any data at all.
>>>>
>>> google for: lucene field existence
>>>
>>> There's no way built in, one strategy[1] is to have a 'meta field'
>>> that contains the names of the fields the document contains.
>>>
>>> --tim
>>>
>>> [1] -
>>> http://www.mail-archive.com/lucene-user@jakarta.apache.org/msg07703.html
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>>
>>>
>>>
>> --
>> 王巍巍(Weiwei Wang)
>> Department of Computer Science
>> Gulou Campus of Nanjing University
>> Nanjing, P.R.China, 210093
>>
>> Mobile: 86-13913310569
>> MSN: ww.wang.cs@gmail.com
>> Homepage: http://cs.nju.edu.cn/rl/weiweiwang
>>
>>
>
>
--
Matthew Hall
Software Engineer
Mouse Genome Informatics
mhall@informatics.jax.org
(207) 288-6012
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Query any data
Posted by Erick Erickson <er...@gmail.com>.
searching for fieldname:* will be *extremely* expensive as it will, by
default,
build a giant OR clause consisting of every term in the field. You'll throw
MaxClauses exceptions right and left. I'd follow Tim's thread lead first....
Best
Erick
2009/4/8 王巍巍 <ww...@gmail.com>
> first you should change your querypaser to accept wildcard query by calling
> method of QueryParser
> setAllowLeadingWildcard
> then you can query like this: fieldname:*
>
> 2009/4/9 Tim Williams <wi...@gmail.com>
>
> > On Wed, Apr 8, 2009 at 11:45 AM, addman <ad...@yahoo.com> wrote:
> > >
> > > Hi,
> > > Is it possible to create a query to search a field for any value? I
> > just
> > > need to know if the optional field contain any data at all.
> >
> > google for: lucene field existence
> >
> > There's no way built in, one strategy[1] is to have a 'meta field'
> > that contains the names of the fields the document contains.
> >
> > --tim
> >
> > [1] -
> > http://www.mail-archive.com/lucene-user@jakarta.apache.org/msg07703.html
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>
>
> --
> 王巍巍(Weiwei Wang)
> Department of Computer Science
> Gulou Campus of Nanjing University
> Nanjing, P.R.China, 210093
>
> Mobile: 86-13913310569
> MSN: ww.wang.cs@gmail.com
> Homepage: http://cs.nju.edu.cn/rl/weiweiwang
>
Re: Query any data
Posted by 王巍巍 <ww...@gmail.com>.
first you should change your querypaser to accept wildcard query by calling
method of QueryParser
setAllowLeadingWildcard
then you can query like this: fieldname:*
2009/4/9 Tim Williams <wi...@gmail.com>
> On Wed, Apr 8, 2009 at 11:45 AM, addman <ad...@yahoo.com> wrote:
> >
> > Hi,
> > Is it possible to create a query to search a field for any value? I
> just
> > need to know if the optional field contain any data at all.
>
> google for: lucene field existence
>
> There's no way built in, one strategy[1] is to have a 'meta field'
> that contains the names of the fields the document contains.
>
> --tim
>
> [1] -
> http://www.mail-archive.com/lucene-user@jakarta.apache.org/msg07703.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
--
王巍巍(Weiwei Wang)
Department of Computer Science
Gulou Campus of Nanjing University
Nanjing, P.R.China, 210093
Mobile: 86-13913310569
MSN: ww.wang.cs@gmail.com
Homepage: http://cs.nju.edu.cn/rl/weiweiwang
Re: Query any data
Posted by Tim Williams <wi...@gmail.com>.
On Wed, Apr 8, 2009 at 11:45 AM, addman <ad...@yahoo.com> wrote:
>
> Hi,
> Is it possible to create a query to search a field for any value? I just
> need to know if the optional field contain any data at all.
google for: lucene field existence
There's no way built in, one strategy[1] is to have a 'meta field'
that contains the names of the fields the document contains.
--tim
[1] - http://www.mail-archive.com/lucene-user@jakarta.apache.org/msg07703.html
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org