Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

Getting Payload from Hits

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


Allahbaksh_Asadullah at infosys

Feb 11, 2008, 5:46 AM

Post #1 of 6 (1074 views)
Permalink
Getting Payload from Hits

Hi,
I have saved payload in my index. When the user types the query I get HIT document. From HIT document how I can get the value of Payload for particular tree.

For example
_analyzer = new PayloadAnalyzer();
_writer = new IndexWriter(new File("d:/test1"), _analyzer, true);
for (int i = 0; i < 10; i++) {
Document d = new Document();
d.add(new Field("f1", "This field has no payloads", Field.Store.NO, Field.Index.TOKENIZED));
d.add(new Field("f2", "This field has payloads in all docs", Field.Store.YES, Field.Index.TOKENIZED));
Integer i1 = i;
byte []payLoadData = null;
payLoadData[0] = i1.byteValue();
_analyzer.setPayloadData("f2", payLoadData);
_writer.addDocument(d);

}
writer.optimize();
// flush
writer.close();
String queryString = "payloads + doc";
System.out.println("Reading Payload Data will begin now");

_parser = new QueryParser("f2", new PayloadAnalyzer());
_searcher = new IndexSearcher("d:/test1");
Query query =_parser.parse(queryString);
Hits hits = _searcher.search(query);
for (int i = 0; i < hits.length(); i++) {
Document doc = hits.doc(i);


Here I want to get the value of payload for the field..
Please let me know how I can get value of payload for a field from Hits
}
Thanks in Advance
Warm Regards,
Allahbaksh




**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***


karl.wettin at gmail

Feb 11, 2008, 7:22 AM

Post #2 of 6 (1025 views)
Permalink
Re: Getting Payload from Hits [In reply to]

11 feb 2008 kl. 14.46 skrev Allahbaksh Mohammedali Asadullah:

> d.add(new Field("f1", "This field has no payloads", Field.Store.NO,
> Field.Index.TOKENIZED));
> d.add(new Field("f2", "This field has payloads in all docs",
> Field.Store.YES, Field.Index.TOKENIZED));

> Document doc = hits.doc(i);
>
> Here I want to get the value of payload for the field..

Are you confusing payloads with stored field values?

You retreive the /stored field value/ like this:

doc.get("f2");

You "can not" retreive /payloads/ from Hits.



karl

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


Allahbaksh_Asadullah at infosys

Feb 11, 2008, 7:51 AM

Post #3 of 6 (1020 views)
Permalink
RE: Getting Payload from Hits [In reply to]

Hi,
Thanks for the reply. But is there any way that from the search result I can get Payload.

See my requirement is when user search for some field I want to display also additional data which is stored as Payload.

Regards,
Allahbaksh




-----Original Message-----
From: Karl Wettin [mailto:karl.wettin [at] gmail]
Sent: Monday, February 11, 2008 8:52 PM
To: java-user [at] lucene
Subject: Re: Getting Payload from Hits


11 feb 2008 kl. 14.46 skrev Allahbaksh Mohammedali Asadullah:

> d.add(new Field("f1", "This field has no payloads", Field.Store.NO,
> Field.Index.TOKENIZED));
> d.add(new Field("f2", "This field has payloads in all docs",
> Field.Store.YES, Field.Index.TOKENIZED));

> Document doc = hits.doc(i);
>
> Here I want to get the value of payload for the field..

Are you confusing payloads with stored field values?

You retreive the /stored field value/ like this:

doc.get("f2");

You "can not" retreive /payloads/ from Hits.



karl

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


karl.wettin at gmail

Feb 11, 2008, 8:22 AM

Post #4 of 6 (1021 views)
Permalink
Re: Getting Payload from Hits [In reply to]

You would have to collect the payloads from matching terms by
extending a query.

See this recent thread:
http://www.nabble.com/Faceting-with-payloads-td15322956.html#a15322956

Are you sure this is what you want to do? What is it you store in the
payloads, and how do you plan to use this information once you have
retreived it?


karl

11 feb 2008 kl. 16.51 skrev Allahbaksh Mohammedali Asadullah:

>
> Hi,
> Thanks for the reply. But is there any way that from the search
> result I can get Payload.
>
> See my requirement is when user search for some field I want to
> display also additional data which is stored as Payload.
>
> Regards,
> Allahbaksh
>
>
>
>
> -----Original Message-----
> From: Karl Wettin [mailto:karl.wettin [at] gmail]
> Sent: Monday, February 11, 2008 8:52 PM
> To: java-user [at] lucene
> Subject: Re: Getting Payload from Hits
>
>
> 11 feb 2008 kl. 14.46 skrev Allahbaksh Mohammedali Asadullah:
>
>> d.add(new Field("f1", "This field has no payloads", Field.Store.NO,
>> Field.Index.TOKENIZED));
>> d.add(new Field("f2", "This field has payloads in all docs",
>> Field.Store.YES, Field.Index.TOKENIZED));
>
>> Document doc = hits.doc(i);
>>
>> Here I want to get the value of payload for the field..
>
> Are you confusing payloads with stored field values?
>
> You retreive the /stored field value/ like this:
>
> doc.get("f2");
>
> You "can not" retreive /payloads/ from Hits.
>
>
>
> karl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION
> intended solely for the use of the addressee(s). If you are not the
> intended recipient, please notify the sender by e-mail and delete
> the original message. Further, you are not to copy, disclose, or
> distribute this e-mail or its contents to any other person and any
> such actions are unlawful. This e-mail may contain viruses. Infosys
> has taken every reasonable precaution to minimize this risk, but is
> not liable for any damage you may sustain as a result of any virus
> in this e-mail. You should carry out your own virus checks before
> opening the e-mail or attachment. Infosys reserves the right to
> monitor and review the content of all messages sent to or from this
> e-mail address. Messages sent to or from this e-mail address may be
> stored on the Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


gsingers at apache

Feb 11, 2008, 9:15 AM

Post #5 of 6 (1019 views)
Permalink
Re: Getting Payload from Hits [In reply to]

Right now there is not a good way, other than to use the
TermPositions. See https://issues.apache.org/jira/browse/LUCENE-1001
for some thoughts on adding the ability. Unfortunately, I ran into a
roadblock, and haven't been able to get back to it. If you feel you
can submit a patch, it would be most welcome.

-Grant


On Feb 11, 2008, at 10:51 AM, Allahbaksh Mohammedali Asadullah wrote:

>
> Hi,
> Thanks for the reply. But is there any way that from the search
> result I can get Payload.
>
> See my requirement is when user search for some field I want to
> display also additional data which is stored as Payload.
>
> Regards,
> Allahbaksh
>
>
>
>
> -----Original Message-----
> From: Karl Wettin [mailto:karl.wettin [at] gmail]
> Sent: Monday, February 11, 2008 8:52 PM
> To: java-user [at] lucene
> Subject: Re: Getting Payload from Hits
>
>
> 11 feb 2008 kl. 14.46 skrev Allahbaksh Mohammedali Asadullah:
>
>> d.add(new Field("f1", "This field has no payloads", Field.Store.NO,
>> Field.Index.TOKENIZED));
>> d.add(new Field("f2", "This field has payloads in all docs",
>> Field.Store.YES, Field.Index.TOKENIZED));
>
>> Document doc = hits.doc(i);
>>
>> Here I want to get the value of payload for the field..
>
> Are you confusing payloads with stored field values?
>
> You retreive the /stored field value/ like this:
>
> doc.get("f2");
>
> You "can not" retreive /payloads/ from Hits.
>
>
>
> karl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION
> intended solely for the use of the addressee(s). If you are not the
> intended recipient, please notify the sender by e-mail and delete
> the original message. Further, you are not to copy, disclose, or
> distribute this e-mail or its contents to any other person and any
> such actions are unlawful. This e-mail may contain viruses. Infosys
> has taken every reasonable precaution to minimize this risk, but is
> not liable for any damage you may sustain as a result of any virus
> in this e-mail. You should carry out your own virus checks before
> opening the e-mail or attachment. Infosys reserves the right to
> monitor and review the content of all messages sent to or from this
> e-mail address. Messages sent to or from this e-mail address may be
> stored on the Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>

--------------------------
Grant Ingersoll
http://lucene.grantingersoll.com
http://www.lucenebootcamp.com

Lucene Helpful Hints:
http://wiki.apache.org/lucene-java/BasicsOfPerformance
http://wiki.apache.org/lucene-java/LuceneFAQ





---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


Allahbaksh_Asadullah at infosys

Feb 11, 2008, 10:57 PM

Post #6 of 6 (1032 views)
Permalink
RE: Getting Payload from Hits [In reply to]

Hi,
Karl thanks for the reply. But I am not able follow you. Should I extend Query class and How should I get matching term. Can you please elaborate on it.
Regards,
Allahbakhs




-----Original Message-----
From: Karl Wettin [mailto:karl.wettin [at] gmail]
Sent: Monday, February 11, 2008 9:53 PM
To: java-user [at] lucene
Subject: Re: Getting Payload from Hits

You would have to collect the payloads from matching terms by
extending a query.

See this recent thread:
http://www.nabble.com/Faceting-with-payloads-td15322956.html#a15322956

Are you sure this is what you want to do? What is it you store in the
payloads, and how do you plan to use this information once you have
retreived it?


karl

11 feb 2008 kl. 16.51 skrev Allahbaksh Mohammedali Asadullah:

>
> Hi,
> Thanks for the reply. But is there any way that from the search
> result I can get Payload.
>
> See my requirement is when user search for some field I want to
> display also additional data which is stored as Payload.
>
> Regards,
> Allahbaksh
>
>
>
>
> -----Original Message-----
> From: Karl Wettin [mailto:karl.wettin [at] gmail]
> Sent: Monday, February 11, 2008 8:52 PM
> To: java-user [at] lucene
> Subject: Re: Getting Payload from Hits
>
>
> 11 feb 2008 kl. 14.46 skrev Allahbaksh Mohammedali Asadullah:
>
>> d.add(new Field("f1", "This field has no payloads", Field.Store.NO,
>> Field.Index.TOKENIZED));
>> d.add(new Field("f2", "This field has payloads in all docs",
>> Field.Store.YES, Field.Index.TOKENIZED));
>
>> Document doc = hits.doc(i);
>>
>> Here I want to get the value of payload for the field..
>
> Are you confusing payloads with stored field values?
>
> You retreive the /stored field value/ like this:
>
> doc.get("f2");
>
> You "can not" retreive /payloads/ from Hits.
>
>
>
> karl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION
> intended solely for the use of the addressee(s). If you are not the
> intended recipient, please notify the sender by e-mail and delete
> the original message. Further, you are not to copy, disclose, or
> distribute this e-mail or its contents to any other person and any
> such actions are unlawful. This e-mail may contain viruses. Infosys
> has taken every reasonable precaution to minimize this risk, but is
> not liable for any damage you may sustain as a result of any virus
> in this e-mail. You should carry out your own virus checks before
> opening the e-mail or attachment. Infosys reserves the right to
> monitor and review the content of all messages sent to or from this
> e-mail address. Messages sent to or from this e-mail address may be
> stored on the Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.