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 sam <ha...@yahoo.com.cn> on 2012/07/06 05:16:23 UTC

about some seacher(I'm new hand, thank you for help)

I want seach a txt ,which is store like  <2012-07-06 11:11:43    some
message> at one line .How to seach that,I need get the time and content.

--
View this message in context: http://lucene.472066.n3.nabble.com/about-some-seacher-I-m-new-hand-thank-you-for-help-tp3993397.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: about some seacher(I'm new hand, thank you for help)

Posted by sam <ha...@yahoo.com.cn>.
thank you very much. it's good for me.

--- 12年7月10日,周二, feng lu [via Lucene] <ml...@n3.nabble.com> 写道:

发件人: feng lu [via Lucene] <ml...@n3.nabble.com>
主题: Re: about some seacher(I'm new hand, thank you for help)
收件人: "sam" <ha...@yahoo.com.cn>
日期: 2012年7月10日,周二,下午4:25



	hi sam


you can add content and time stamp field like this.


// add content

 doc.add(new Field("contents", content,Field.Store.NO,Field.Index.ANALYZED);

 // add timestamp

 NumericField timestampField = new NumericField("timestamp");

 timestampField.setLongValue(DateField.stringToTime(timestamp));

 doc.add(timestampField);


To perform range querying or filtering against a NumericField, use

NumericRangeQuery or NumericRangeFilter. you can see the

http://wiki.apache.org/lucene-java/SearchNumericalFields to find any useful

information.


On Tue, Jul 10, 2012 at 3:38 PM, sam <[hidden email]> wrote:


> timestamp





-- 

Don't Grow Old, Grow Up... :-)


	
	

	

	
	
		If you reply to this email, your message will be added to the discussion below:
		http://lucene.472066.n3.nabble.com/about-some-seacher-I-m-new-hand-thank-you-for-help-tp3993397p3994094.html
	
	
		
		To unsubscribe from about some seacher(I'm new hand, thank you for help), click here.

		NAML
	

--
View this message in context: http://lucene.472066.n3.nabble.com/about-some-seacher-I-m-new-hand-thank-you-for-help-tp3993397p3994102.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

Re: about some seacher(I'm new hand, thank you for help)

Posted by feng lu <am...@gmail.com>.
hi sam

you can add content and time stamp field like this.

// add content
 doc.add(new Field("contents", content,Field.Store.NO,Field.Index.ANALYZED);
 // add timestamp
 NumericField timestampField = new NumericField("timestamp");
 timestampField.setLongValue(DateField.stringToTime(timestamp));
 doc.add(timestampField);

To perform range querying or filtering against a NumericField, use
NumericRangeQuery or NumericRangeFilter. you can see the
http://wiki.apache.org/lucene-java/SearchNumericalFields to find any useful
information.

On Tue, Jul 10, 2012 at 3:38 PM, sam <ha...@yahoo.com.cn> wrote:

> timestamp




-- 
Don't Grow Old, Grow Up... :-)

Re: about some seacher(I'm new hand, thank you for help)

Posted by sam <ha...@yahoo.com.cn>.
but,how can i used it in lucene
			File logFile= new File("D:\\logFile"); 
			BufferedReader reader=null;
			String str = null;
			reader = new BufferedReader(new FileReader(logFile));
			while ((str=reader.readLine())!=null) {
				String timestamp = str.substring(1, 13);
				String content = str.substring(14).trim();
			}
in  this way ,we can get the data,but
document.add(new Field("content",
content,Field.Store.YES,Field.Index.NOT_ANALYZED_NO_NORMS);
it's must be wrong.

--
View this message in context: http://lucene.472066.n3.nabble.com/about-some-seacher-I-m-new-hand-thank-you-for-help-tp3993397p3994093.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: about some seacher(I'm new hand, thank you for help)

Posted by Ian Lea <ia...@gmail.com>.
You don't know how to split the string containing the data you want to index??

	String s = "2012-07-06 11:11:43    some message";
	String timestamp = s.substring(0, 19);
	String content = s.substring(19).trim();

is one way.


--
Ian.


On Mon, Jul 9, 2012 at 3:55 AM, sam <ha...@yahoo.com.cn> wrote:
> But i don't konw how to split this two data,this is the piont.would you mind
> writing down some codes to show that?thank you very much !
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/about-some-seacher-I-m-new-hand-thank-you-for-help-tp3993397p3993808.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


Re: about some seacher(I'm new hand, thank you for help)

Posted by sam <ha...@yahoo.com.cn>.
But i don't konw how to split this two data,this is the piont.would you mind
writing down some codes to show that?thank you very much !

--
View this message in context: http://lucene.472066.n3.nabble.com/about-some-seacher-I-m-new-hand-thank-you-for-help-tp3993397p3993808.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: about some seacher(I'm new hand, thank you for help)

Posted by Ian Lea <ia...@gmail.com>.
Split the data into 2 fields, timestamp and content.  Store one lucene
document per line with the 2 fields, timestamp stored and not indexed
(unless you want to search on it), content stored and analyzed.  Use
StandardAnalyzer unless you have special requirements.

Then close the IndexWriter, open a searcher, use QueryParser to get a
query for "content: some message", search, get and display the
timestamp and content fields and you're done.

Googling "lucene tutorial" or "lucene getting started" will get hits.
Or look at the sample/demo code at
http://lucene.apache.org/core/quickstart.html.  Or, best of all, get
hold of a copy of Lucene In Action 2nd. edition.


Or take a look at Solr.


--
Ian.


On Fri, Jul 6, 2012 at 4:16 AM, sam <ha...@yahoo.com.cn> wrote:
> I want seach a txt ,which is store like  <2012-07-06 11:11:43    some
> message> at one line .How to seach that,I need get the time and content.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/about-some-seacher-I-m-new-hand-thank-you-for-help-tp3993397.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