Is it possible to query for docs that do not have a specific field present?

Thanks.

J

Search Discussions

  • Jerry Camel at Dec 16, 2009 at 6:18 pm
    Anyone? ... Does no response mean it's not possible or that it's such a
    newbie question that nobody will dignify it with a response?

    J

    --------------------------------------------------
    From: "Jerry Camel" <rlrcstr@msn.com>
    Sent: Tuesday, December 15, 2009 11:35 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Query For Unpopulated Fields
    Is it possible to query for docs that do not have a specific field
    present?

    Thanks.

    J
  • Shashi Kant at Dec 16, 2009 at 9:14 pm
    Jerry, there are several reasons other members might have stayed quiet. I
    will give you mine. Your question did not make sense to me and it would be
    helpful if you could elaborate a bit without being too verbose.

    I am guessing you are looking for something like the EXCLUDE statement in
    SQL. I am not aware of any Lucene method that would do it. But you could
    approach it by storing the *fieldname* itself as a value in your index and
    query.

    hth
    On Wed, Dec 16, 2009 at 1:17 PM, Jerry Camel wrote:

    Anyone? ... Does no response mean it's not possible or that it's such a
    newbie question that nobody will dignify it with a response?

    J

    --------------------------------------------------
    From: "Jerry Camel" <rlrcstr@msn.com>
    Sent: Tuesday, December 15, 2009 11:35 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Query For Unpopulated Fields


    Is it possible to query for docs that do not have a specific field
    present?

    Thanks.

    J
  • Jerry Camel at Dec 16, 2009 at 9:24 pm
    Okay... I stored a bunch of documents. One of the fields is called
    "hasattachments". If the document has an attachment, I stored the value
    "true" in that field. I didn't do the converse... I never stored "false"
    if the document didn't have attachments. So it appears that documents
    without attachments don't have that field. So I was trying to devise a way
    to query for all documents that don't have attachments.

    Does that clear it up?

    Thanks.

    Jerry

    --------------------------------------------------
    From: "Shashi Kant" <skant@sloan.mit.edu>
    Sent: Wednesday, December 16, 2009 4:13 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Re: Query For Unpopulated Fields
    Jerry, there are several reasons other members might have stayed quiet. I
    will give you mine. Your question did not make sense to me and it would be
    helpful if you could elaborate a bit without being too verbose.

    I am guessing you are looking for something like the EXCLUDE statement in
    SQL. I am not aware of any Lucene method that would do it. But you could
    approach it by storing the *fieldname* itself as a value in your index and
    query.

    hth
    On Wed, Dec 16, 2009 at 1:17 PM, Jerry Camel wrote:

    Anyone? ... Does no response mean it's not possible or that it's such a
    newbie question that nobody will dignify it with a response?

    J

    --------------------------------------------------
    From: "Jerry Camel" <rlrcstr@msn.com>
    Sent: Tuesday, December 15, 2009 11:35 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Query For Unpopulated Fields


    Is it possible to query for docs that do not have a specific field
    present?

    Thanks.

    J
  • Michael Garski at Dec 16, 2009 at 9:39 pm
    Jerry,

    If you want to query for items without attachments you will want to
    index them with the value of 'false' in that field.

    Michael
    On Dec 16, 2009, at 1:24 PM, "Jerry Camel" wrote:

    Okay... I stored a bunch of documents. One of the fields is called
    "hasattachments". If the document has an attachment, I stored the
    value "true" in that field. I didn't do the converse... I never
    stored "false" if the document didn't have attachments. So it
    appears that documents without attachments don't have that field.
    So I was trying to devise a way to query for all documents that
    don't have attachments.

    Does that clear it up?

    Thanks.

    Jerry

    --------------------------------------------------
    From: "Shashi Kant" <skant@sloan.mit.edu>
    Sent: Wednesday, December 16, 2009 4:13 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Re: Query For Unpopulated Fields
    Jerry, there are several reasons other members might have stayed
    quiet. I
    will give you mine. Your question did not make sense to me and it
    would be
    helpful if you could elaborate a bit without being too verbose.

    I am guessing you are looking for something like the EXCLUDE
    statement in
    SQL. I am not aware of any Lucene method that would do it. But you
    could
    approach it by storing the *fieldname* itself as a value in your
    index and
    query.

    hth
    On Wed, Dec 16, 2009 at 1:17 PM, Jerry Camel wrote:

    Anyone? ... Does no response mean it's not possible or that it's
    such a
    newbie question that nobody will dignify it with a response?

    J

    --------------------------------------------------
    From: "Jerry Camel" <rlrcstr@msn.com>
    Sent: Tuesday, December 15, 2009 11:35 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Query For Unpopulated Fields


    Is it possible to query for docs that do not have a specific field
    present?

    Thanks.

    J
  • Jerry Camel at Dec 16, 2009 at 9:43 pm
    I have since updated my code to do just that... So to "fix" this, I need to
    iterate through all the docs in the index and add in a false value if the
    "hasattachments" field is not present.

    Is there a specific test for presence of a field, or do I just catch an
    exception?

    Thanks.

    --------------------------------------------------
    From: "Michael Garski" <mgarski@myspace-inc.com>
    Sent: Wednesday, December 16, 2009 4:38 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Re: Query For Unpopulated Fields
    Jerry,

    If you want to query for items without attachments you will want to index
    them with the value of 'false' in that field.

    Michael
    On Dec 16, 2009, at 1:24 PM, "Jerry Camel" wrote:

    Okay... I stored a bunch of documents. One of the fields is called
    "hasattachments". If the document has an attachment, I stored the value
    "true" in that field. I didn't do the converse... I never stored
    "false" if the document didn't have attachments. So it appears that
    documents without attachments don't have that field. So I was trying to
    devise a way to query for all documents that don't have attachments.

    Does that clear it up?

    Thanks.

    Jerry

    --------------------------------------------------
    From: "Shashi Kant" <skant@sloan.mit.edu>
    Sent: Wednesday, December 16, 2009 4:13 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Re: Query For Unpopulated Fields
    Jerry, there are several reasons other members might have stayed quiet.
    I
    will give you mine. Your question did not make sense to me and it would
    be
    helpful if you could elaborate a bit without being too verbose.

    I am guessing you are looking for something like the EXCLUDE statement
    in
    SQL. I am not aware of any Lucene method that would do it. But you
    could
    approach it by storing the *fieldname* itself as a value in your index
    and
    query.

    hth
    On Wed, Dec 16, 2009 at 1:17 PM, Jerry Camel wrote:

    Anyone? ... Does no response mean it's not possible or that it's such
    a
    newbie question that nobody will dignify it with a response?

    J

    --------------------------------------------------
    From: "Jerry Camel" <rlrcstr@msn.com>
    Sent: Tuesday, December 15, 2009 11:35 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Query For Unpopulated Fields


    Is it possible to query for docs that do not have a specific field
    present?

    Thanks.

    J
  • Michael Garski at Dec 16, 2009 at 9:47 pm
    Jerry,

    You can't add a field to an existing document, but have to delete and
    reindex the item.

    I'd suggest a copy of Lucene in Action to get started with those basics.

    Michael
    On Dec 16, 2009, at 1:43 PM, "Jerry Camel" wrote:

    I have since updated my code to do just that... So to "fix" this, I
    need to iterate through all the docs in the index and add in a false
    value if the "hasattachments" field is not present.

    Is there a specific test for presence of a field, or do I just catch
    an exception?

    Thanks.

    --------------------------------------------------
    From: "Michael Garski" <mgarski@myspace-inc.com>
    Sent: Wednesday, December 16, 2009 4:38 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Re: Query For Unpopulated Fields
    Jerry,

    If you want to query for items without attachments you will want
    to index them with the value of 'false' in that field.

    Michael
    On Dec 16, 2009, at 1:24 PM, "Jerry Camel" wrote:

    Okay... I stored a bunch of documents. One of the fields is
    called "hasattachments". If the document has an attachment, I
    stored the value "true" in that field. I didn't do the
    converse... I never stored "false" if the document didn't have
    attachments. So it appears that documents without attachments
    don't have that field. So I was trying to devise a way to query
    for all documents that don't have attachments.

    Does that clear it up?

    Thanks.

    Jerry

    --------------------------------------------------
    From: "Shashi Kant" <skant@sloan.mit.edu>
    Sent: Wednesday, December 16, 2009 4:13 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Re: Query For Unpopulated Fields
    Jerry, there are several reasons other members might have stayed
    quiet. I
    will give you mine. Your question did not make sense to me and
    it would be
    helpful if you could elaborate a bit without being too verbose.

    I am guessing you are looking for something like the EXCLUDE
    statement in
    SQL. I am not aware of any Lucene method that would do it. But
    you could
    approach it by storing the *fieldname* itself as a value in your
    index and
    query.

    hth

    On Wed, Dec 16, 2009 at 1:17 PM, Jerry Camel <rlrcstr@msn.com>
    wrote:
    Anyone? ... Does no response mean it's not possible or that
    it's such a
    newbie question that nobody will dignify it with a response?

    J

    --------------------------------------------------
    From: "Jerry Camel" <rlrcstr@msn.com>
    Sent: Tuesday, December 15, 2009 11:35 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Query For Unpopulated Fields


    Is it possible to query for docs that do not have a specific field
    present?

    Thanks.

    J
  • Shashi Kant at Dec 16, 2009 at 9:44 pm
    try, a boolean query with a MUST_NOT clause. something like...

    BooleanQuery bq = new BooleanQuery()
    Query noattach = qp.Parse("hasAttachments",...)
    bq.Add(noattach, BooleanClause.Occur.MUST_NOT)

    On Dec 16, 2009, at 1:24 PM, "Jerry Camel" wrote:

    Okay... I stored a bunch of documents. One of the fields is called
    "hasattachments". If the document has an attachment, I stored the value
    "true" in that field. I didn't do the converse... I never stored "false"
    if the document didn't have attachments. So it appears that documents
    without attachments don't have that field. So I was trying to devise a way
    to query for all documents that don't have attachments.

    Does that clear it up?

    Thanks.

    Jerry

    --------------------------------------------------
    From: "Shashi Kant" <skant@sloan.mit.edu>
    Sent: Wednesday, December 16, 2009 4:13 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Re: Query For Unpopulated Fields

    Jerry, there are several reasons other members might have stayed quiet. I
    will give you mine. Your question did not make sense to me and it would
    be
    helpful if you could elaborate a bit without being too verbose.

    I am guessing you are looking for something like the EXCLUDE statement in
    SQL. I am not aware of any Lucene method that would do it. But you could
    approach it by storing the *fieldname* itself as a value in your index
    and
    query.

    hth

    On Wed, Dec 16, 2009 at 1:17 PM, Jerry Camel wrote:

    Anyone? ... Does no response mean it's not possible or that it's such a
    newbie question that nobody will dignify it with a response?

    J

    --------------------------------------------------
    From: "Jerry Camel" <rlrcstr@msn.com>
    Sent: Tuesday, December 15, 2009 11:35 PM
    To: <lucene-net-user@incubator.apache.org>
    Subject: Query For Unpopulated Fields


    Is it possible to query for docs that do not have a specific field
    present?

    Thanks.

    J

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouplucene-net-user @
categorieslucene
postedDec 16, '09 at 4:35a
activeDec 16, '09 at 9:47p
posts8
users3
websitelucene.apache.org

People

Translate

site design / logo © 2022 Grokbase