FAQ
Hey!

Consider a bunch of documents that represent, say, students. These students
have the following attributes:
1) Student IDs
2) Name
3) Self-description (optional)

So, all documents have id: and name:, but only some of the documents have an
added desc:

Assuming all of the fields are indexed, I can certainly search within any of
the fields. That is: "+name:John desc:muffins" searches for students named
John who mentioned "muffins" in their description.

What I want is all documents that contain the self-description field,
regardless of what that field contains.

I can probably do this: "desc:*", but I'm not sure how efficient that'd be,
and I wonder if there's a better way to do it.

Thank you!
-Matt
--
View this message in context: http://www.nabble.com/Searching-documents-that-contain-a-field-%28text-of-field-is-irrelevant%29-tp23826263p23826263.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

Search Discussions

  • Balasubramanian sudaakeran at Jun 2, 2009 at 4:51 am
    Couple of approaches. (But not very sure if there are other better approaches)
    1. Add a seperate field which is set to 1 or 0 depending upon if the self description is present or not. Then you can search by this new field.
    2. Along with each self-descrition add a common idenfier word. Then you can search by this idenfier word.



    ----- Original Message ----
    From: mattspitz <mspitz@stanford.edu>
    To: java-user@lucene.apache.org
    Sent: Tuesday, June 2, 2009 9:50:51 AM
    Subject: Searching documents that contain a field (text of field is irrelevant)


    Hey!

    Consider a bunch of documents that represent, say, students.  These students
    have the following attributes:
    1) Student IDs
    2) Name
    3) Self-description (optional)

    So, all documents have id: and name:, but only some of the documents have an
    added desc:

    Assuming all of the fields are indexed, I can certainly search within any of
    the fields.  That is: "+name:John desc:muffins" searches for students named
    John who mentioned "muffins" in their description.

    What I want is all documents that contain the self-description field,
    regardless of what that field contains.

    I can probably do this: "desc:*", but I'm not sure how efficient that'd be,
    and I wonder if there's a better way to do it.

    Thank you!
    -Matt
    --
    View this message in context: http://www.nabble.com/Searching-documents-that-contain-a-field-%28text-of-field-is-irrelevant%29-tp23826263p23826263.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




    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Digy at Jun 2, 2009 at 5:53 pm
    Or
    searcher.search( new PrefixQuery( new Term("desc","") ) );

    DIGY

    -----Original Message-----
    From: balasubramanian sudaakeran
    Sent: Tuesday, June 02, 2009 7:51 AM
    To: java-user@lucene.apache.org
    Subject: Re: Searching documents that contain a field (text of field is
    irrelevant)


    Couple of approaches. (But not very sure if there are other better
    approaches)
    1. Add a seperate field which is set to 1 or 0 depending upon if the self
    description is present or not. Then you can search by this new field.
    2. Along with each self-descrition add a common idenfier word. Then you can
    search by this idenfier word.



    ----- Original Message ----
    From: mattspitz <mspitz@stanford.edu>
    To: java-user@lucene.apache.org
    Sent: Tuesday, June 2, 2009 9:50:51 AM
    Subject: Searching documents that contain a field (text of field is
    irrelevant)


    Hey!

    Consider a bunch of documents that represent, say, students.  These students
    have the following attributes:
    1) Student IDs
    2) Name
    3) Self-description (optional)

    So, all documents have id: and name:, but only some of the documents have an
    added desc:

    Assuming all of the fields are indexed, I can certainly search within any of
    the fields.  That is: "+name:John desc:muffins" searches for students named
    John who mentioned "muffins" in their description.

    What I want is all documents that contain the self-description field,
    regardless of what that field contains.

    I can probably do this: "desc:*", but I'm not sure how efficient that'd be,
    and I wonder if there's a better way to do it.

    Thank you!
    -Matt
    --
    View this message in context:
    http://www.nabble.com/Searching-documents-that-contain-a-field-%28text-of-fi
    eld-is-irrelevant%29-tp23826263p23826263.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




    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedJun 2, '09 at 4:21a
activeJun 2, '09 at 5:53p
posts3
users3
websitelucene.apache.org

People

Translate

site design / logo © 2021 Grokbase