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 AnkitSinghal <an...@gmail.com> on 2007/09/10 15:53:06 UTC

Storing Host and IP Information in Lucene

Hi

I have query about storing hostname and IP information in lucene,

For eg: In my Application I have some field with name host.
In my App sometimes i get value as host name and sometimes as ipaddress.
like sometimes i get ankit.xyz.com and sometimes i get 10.10.01.01

In my code i have made the Lucene field as
Field("host",value,TOKENIZED,NOSTORE).

Now the problem with above is that I cannot search for host:10.10.*

And if i make the field as UNTOKENIZED  i cannot search for queries like
host:xyz.* .

The only solution that came to my mind is to parse the value and decide if
it contains the IPaddress or hostname and then decide which type of
tokenizing to use.

But this seems to a pretty big overhead as my data us huge and parsing for
each record is not feasible.

Can any body provide with some better approach. I believe this is a very
common problem.

Ankit
-- 
View this message in context: http://www.nabble.com/Storing-Host-and-IP-Information-in-Lucene-tf4414865.html#a12593257
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: Storing Host and IP Information in Lucene

Posted by Erick Erickson <er...@gmail.com>.
What kind of analyzers are you using for this? Might it work for you
to put it in a special field and analyze and search with, say,
WhitespaceAnalyzer (or an analyzer that lowercases and breaks
on whitespace)?

PerFIeldAnalyzerWrapper is your friend.

Best
Erick

On 9/10/07, AnkitSinghal <an...@gmail.com> wrote:
>
>
> But i think the query like host:example* will not work in this case
> Actually it was typo in my question. I want to search for above type of
> query only.
>
> Ankit
>
>
> Daniel Noll-3 wrote:
> >
> > On Monday 10 September 2007 23:53:06 AnkitSinghal wrote:
> >> And if i make the field as UNTOKENIZED  i cannot search for queries
> like
> >> host:xyz.* .
> >
> > I'm not sure why that wouldn't work.  If the stored token is
> > xyz.example.com,
> > then xyz.* will certainly match it.
> >
> > Daniel
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Storing-Host-and-IP-Information-in-Lucene-tf4414865.html#a12607238
> 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: Storing Host and IP Information in Lucene

Posted by Mike Klaas <mi...@gmail.com>.
On 10-Sep-07, at 8:37 PM, AnkitSinghal wrote:

>
> But i think the query like host:example* will not work in this case
> Actually it was typo in my question. I want to search for above  
> type of
> query only.

Hosts are best stored in reverse domain format:

xyz.example.com -> com.example.xyz

Then you can query docs from example.com via:
(com.example com.example.*)

If you want 'example' to be searchable as a term, then additionally  
store the host in a different, tokenized field.

-Mike

> Ankit
>
>
> Daniel Noll-3 wrote:
>>
>> On Monday 10 September 2007 23:53:06 AnkitSinghal wrote:
>>> And if i make the field as UNTOKENIZED  i cannot search for  
>>> queries like
>>> host:xyz.* .
>>
>> I'm not sure why that wouldn't work.  If the stored token is
>> xyz.example.com,
>> then xyz.* will certainly match it.
>>
>> Daniel
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Storing-Host- 
> and-IP-Information-in-Lucene-tf4414865.html#a12607238
> 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: Storing Host and IP Information in Lucene

Posted by AnkitSinghal <an...@gmail.com>.
But i think the query like host:example* will not work in this case
Actually it was typo in my question. I want to search for above type of
query only.

Ankit


Daniel Noll-3 wrote:
> 
> On Monday 10 September 2007 23:53:06 AnkitSinghal wrote:
>> And if i make the field as UNTOKENIZED  i cannot search for queries like
>> host:xyz.* .
> 
> I'm not sure why that wouldn't work.  If the stored token is
> xyz.example.com, 
> then xyz.* will certainly match it.
> 
> Daniel
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Storing-Host-and-IP-Information-in-Lucene-tf4414865.html#a12607238
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: Storing Host and IP Information in Lucene

Posted by Daniel Noll <da...@nuix.com>.
On Monday 10 September 2007 23:53:06 AnkitSinghal wrote:
> And if i make the field as UNTOKENIZED  i cannot search for queries like
> host:xyz.* .

I'm not sure why that wouldn't work.  If the stored token is xyz.example.com, 
then xyz.* will certainly match it.

Daniel

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