You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Tim Haughton <ti...@gmail.com> on 2009/09/25 15:36:30 UTC
Tagging
Afternoon.
I'm about to add tagging in to my single user document management
application.
- A document will have zeo or more tags.
- I must be able to list all documents with a given tag
No rocket science :) Anyone know any gotchas or have any advice? Is it
something that's commonly done with Lucene? If you've done it, how did you
do it?
Many thanks.
Regards,
Tim Haughton
www.agilemicroisv.com
Chat Skype: timhaughton
Contact Me [image: Linkedin] <http://www.linkedin.com/in/timhaughton>[image:
Facebook] <http://www.facebook.com/timhaughton>[image:
Twitter]<http://www.twitter.com/dokix>
Blog RSS Wordpress update
oddness<http://feedproxy.google.com/%7Er/TheAgileMicroISVBlog/%7E3/mg118P-A8vU/wordpress-update-oddness.html>
Search for member names
Posted by Robert Pohl <ro...@gmail.com>.
Hi,
How do I perform the best query for searching member names such as
"robert alexander pohl".
I want to first display the exact match, and then people that is called
"robert alexander" or "robert pohl" and at last just "robert"
How can I achieve this?
My query looks like this now, bit it doesn show good results:
BooleanQuery query = new BooleanQuery();
Query q1 =
Similarity.Net.SimilarityQueries.FormSimilarQuery(searchQuery, new
StandardAnalyzer(),
"DisplayName", null);
Query q2 =
Similarity.Net.SimilarityQueries.FormSimilarQuery(searchQuery + "*", new
StandardAnalyzer(),
"DisplayName", null);
q1.SetBoost(10f);
query.Add(q1, BooleanClause.Occur.MUST);
query.Add(q2, BooleanClause.Occur.SHOULD);
RE: Tagging
Posted by Digy <di...@gmail.com>.
IndexReader reader = IndexReader.Open(dir);
foreach (string s in
reader.GetFieldNames(IndexReader.FieldOption.ALL))
{
Console.WriteLine(s);
}
DIGY
-----Original Message-----
From: Tim Haughton [mailto:timhaughton@gmail.com]
Sent: Friday, September 25, 2009 5:02 PM
To: lucene-net-user@incubator.apache.org
Subject: Re: Tagging
Sounds simple enough.
Can you get a list of tags in the index? Or do you have to keep an external
list?
Tim
2009/9/25 Michael Neel <mi...@gmail.com>
> I have added a "tag" field for every tag on a document. Depending on
> how you want searches to work, and what makes up a valid tag, you may
> not want to tokenize this field. Having this tag it is own field
> makes it easy to weight tags up in a search, and have the options to
> search exclusively by tag.
>
> Mike
>
> On Fri, Sep 25, 2009 at 9:36 AM, Tim Haughton <ti...@gmail.com>
> wrote:
> > Afternoon.
> >
> > I'm about to add tagging in to my single user document management
> > application.
> >
> > - A document will have zeo or more tags.
> > - I must be able to list all documents with a given tag
> >
> > No rocket science :) Anyone know any gotchas or have any advice? Is it
> > something that's commonly done with Lucene? If you've done it, how did
> you
> > do it?
> >
> > Many thanks.
> >
> > Regards,
> >
> > Tim Haughton
> > www.agilemicroisv.com
> > Chat Skype: timhaughton
> > Contact Me [image: Linkedin] <http://www.linkedin.com/in/timhaughton
> >[image:
> > Facebook] <http://www.facebook.com/timhaughton>[image:
> > Twitter]<http://www.twitter.com/dokix>
> > Blog RSS Wordpress update
> > oddness<
>
http://feedproxy.google.com/%7Er/TheAgileMicroISVBlog/%7E3/mg118P-A8vU/wordp
ress-update-oddness.html
> >
> >
>
>
>
> --
> Michael C. Neel (@ViNull)
> http://www.ViNull.com
> Microsoft MVP & ASPInsider
>
> Do you FeelTheFunc(.com)?
>
Re: Tagging
Posted by Shashi Kant <sk...@sloan.mit.edu>.
It is very much possible to get the list of terms from the index. Here
is the snippet from "Luke" code:
public static TermInfo[] getHighFreqTerms(Directory dir, Hashtable
junkWords, int numTerms, String[] fields) throws Exception {
if (dir == null || fields == null) return null;
IndexReader reader = IndexReader.open(dir);
TermInfoQueue tiq = new TermInfoQueue(numTerms);
TermEnum terms = reader.terms();
int minFreq = 0;
while (terms.next()) {
String field = terms.term().field();
if (fields != null && fields.length > 0) {
boolean skip = true;
for (int i = 0; i < fields.length; i++) {
if (field.equals(fields[i])) {
skip = false;
break;
}
}
if (skip) continue;
}
if (junkWords != null &&
junkWords.get(terms.term().text()) != null) continue;
if (terms.docFreq() > minFreq) {
tiq.put(new TermInfo(terms.term(), terms.docFreq()));
if (tiq.size() >= numTerms) // if tiq overfull
{
tiq.pop(); // remove lowest in tiq
minFreq = ((TermInfo)tiq.top()).docFreq; // reset minFreq
}
}
}
TermInfo[] res = new TermInfo[tiq.size()];
for (int i = 0; i < res.length; i++) {
res[res.length - i - 1] = (TermInfo)tiq.pop();
}
reader.close();
return res;
}
On Fri, Sep 25, 2009 at 10:21 AM, Michael Neel <mi...@gmail.com> wrote:
> I keep an external list, updated when I update the lucene index - You
> could "brute force" it by looping over all documents in the index, and
> I believe it's possible to get a list of indexed terms from lucene
> directly from an index, but that's an area I haven't played with too
> much at this point.
>
> Mike
>
> On Fri, Sep 25, 2009 at 10:01 AM, Tim Haughton <ti...@gmail.com> wrote:
>> Sounds simple enough.
>>
>> Can you get a list of tags in the index? Or do you have to keep an external
>> list?
>>
>> Tim
>>
>> 2009/9/25 Michael Neel <mi...@gmail.com>
>>
>>> I have added a "tag" field for every tag on a document. Depending on
>>> how you want searches to work, and what makes up a valid tag, you may
>>> not want to tokenize this field. Having this tag it is own field
>>> makes it easy to weight tags up in a search, and have the options to
>>> search exclusively by tag.
>>>
>>> Mike
>>>
>>> On Fri, Sep 25, 2009 at 9:36 AM, Tim Haughton <ti...@gmail.com>
>>> wrote:
>>> > Afternoon.
>>> >
>>> > I'm about to add tagging in to my single user document management
>>> > application.
>>> >
>>> > - A document will have zeo or more tags.
>>> > - I must be able to list all documents with a given tag
>>> >
>>> > No rocket science :) Anyone know any gotchas or have any advice? Is it
>>> > something that's commonly done with Lucene? If you've done it, how did
>>> you
>>> > do it?
>>> >
>>> > Many thanks.
>>> >
>>> > Regards,
>>> >
>>> > Tim Haughton
>>> > www.agilemicroisv.com
>>> > Chat Skype: timhaughton
>>> > Contact Me [image: Linkedin] <http://www.linkedin.com/in/timhaughton
>>> >[image:
>>> > Facebook] <http://www.facebook.com/timhaughton>[image:
>>> > Twitter]<http://www.twitter.com/dokix>
>>> > Blog RSS Wordpress update
>>> > oddness<
>>> http://feedproxy.google.com/%7Er/TheAgileMicroISVBlog/%7E3/mg118P-A8vU/wordpress-update-oddness.html
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Michael C. Neel (@ViNull)
>>> http://www.ViNull.com
>>> Microsoft MVP & ASPInsider
>>>
>>> Do you FeelTheFunc(.com)?
>>>
>>
>
>
>
> --
> Michael C. Neel (@ViNull)
> http://www.ViNull.com
> Microsoft MVP & ASPInsider
>
> Do you FeelTheFunc(.com)?
>
Re: Tagging
Posted by Michael Neel <mi...@gmail.com>.
I keep an external list, updated when I update the lucene index - You
could "brute force" it by looping over all documents in the index, and
I believe it's possible to get a list of indexed terms from lucene
directly from an index, but that's an area I haven't played with too
much at this point.
Mike
On Fri, Sep 25, 2009 at 10:01 AM, Tim Haughton <ti...@gmail.com> wrote:
> Sounds simple enough.
>
> Can you get a list of tags in the index? Or do you have to keep an external
> list?
>
> Tim
>
> 2009/9/25 Michael Neel <mi...@gmail.com>
>
>> I have added a "tag" field for every tag on a document. Depending on
>> how you want searches to work, and what makes up a valid tag, you may
>> not want to tokenize this field. Having this tag it is own field
>> makes it easy to weight tags up in a search, and have the options to
>> search exclusively by tag.
>>
>> Mike
>>
>> On Fri, Sep 25, 2009 at 9:36 AM, Tim Haughton <ti...@gmail.com>
>> wrote:
>> > Afternoon.
>> >
>> > I'm about to add tagging in to my single user document management
>> > application.
>> >
>> > - A document will have zeo or more tags.
>> > - I must be able to list all documents with a given tag
>> >
>> > No rocket science :) Anyone know any gotchas or have any advice? Is it
>> > something that's commonly done with Lucene? If you've done it, how did
>> you
>> > do it?
>> >
>> > Many thanks.
>> >
>> > Regards,
>> >
>> > Tim Haughton
>> > www.agilemicroisv.com
>> > Chat Skype: timhaughton
>> > Contact Me [image: Linkedin] <http://www.linkedin.com/in/timhaughton
>> >[image:
>> > Facebook] <http://www.facebook.com/timhaughton>[image:
>> > Twitter]<http://www.twitter.com/dokix>
>> > Blog RSS Wordpress update
>> > oddness<
>> http://feedproxy.google.com/%7Er/TheAgileMicroISVBlog/%7E3/mg118P-A8vU/wordpress-update-oddness.html
>> >
>> >
>>
>>
>>
>> --
>> Michael C. Neel (@ViNull)
>> http://www.ViNull.com
>> Microsoft MVP & ASPInsider
>>
>> Do you FeelTheFunc(.com)?
>>
>
--
Michael C. Neel (@ViNull)
http://www.ViNull.com
Microsoft MVP & ASPInsider
Do you FeelTheFunc(.com)?
Re: Tagging
Posted by Tim Haughton <ti...@gmail.com>.
Sounds simple enough.
Can you get a list of tags in the index? Or do you have to keep an external
list?
Tim
2009/9/25 Michael Neel <mi...@gmail.com>
> I have added a "tag" field for every tag on a document. Depending on
> how you want searches to work, and what makes up a valid tag, you may
> not want to tokenize this field. Having this tag it is own field
> makes it easy to weight tags up in a search, and have the options to
> search exclusively by tag.
>
> Mike
>
> On Fri, Sep 25, 2009 at 9:36 AM, Tim Haughton <ti...@gmail.com>
> wrote:
> > Afternoon.
> >
> > I'm about to add tagging in to my single user document management
> > application.
> >
> > - A document will have zeo or more tags.
> > - I must be able to list all documents with a given tag
> >
> > No rocket science :) Anyone know any gotchas or have any advice? Is it
> > something that's commonly done with Lucene? If you've done it, how did
> you
> > do it?
> >
> > Many thanks.
> >
> > Regards,
> >
> > Tim Haughton
> > www.agilemicroisv.com
> > Chat Skype: timhaughton
> > Contact Me [image: Linkedin] <http://www.linkedin.com/in/timhaughton
> >[image:
> > Facebook] <http://www.facebook.com/timhaughton>[image:
> > Twitter]<http://www.twitter.com/dokix>
> > Blog RSS Wordpress update
> > oddness<
> http://feedproxy.google.com/%7Er/TheAgileMicroISVBlog/%7E3/mg118P-A8vU/wordpress-update-oddness.html
> >
> >
>
>
>
> --
> Michael C. Neel (@ViNull)
> http://www.ViNull.com
> Microsoft MVP & ASPInsider
>
> Do you FeelTheFunc(.com)?
>
Re: Tagging
Posted by Michael Neel <mi...@gmail.com>.
I have added a "tag" field for every tag on a document. Depending on
how you want searches to work, and what makes up a valid tag, you may
not want to tokenize this field. Having this tag it is own field
makes it easy to weight tags up in a search, and have the options to
search exclusively by tag.
Mike
On Fri, Sep 25, 2009 at 9:36 AM, Tim Haughton <ti...@gmail.com> wrote:
> Afternoon.
>
> I'm about to add tagging in to my single user document management
> application.
>
> - A document will have zeo or more tags.
> - I must be able to list all documents with a given tag
>
> No rocket science :) Anyone know any gotchas or have any advice? Is it
> something that's commonly done with Lucene? If you've done it, how did you
> do it?
>
> Many thanks.
>
> Regards,
>
> Tim Haughton
> www.agilemicroisv.com
> Chat Skype: timhaughton
> Contact Me [image: Linkedin] <http://www.linkedin.com/in/timhaughton>[image:
> Facebook] <http://www.facebook.com/timhaughton>[image:
> Twitter]<http://www.twitter.com/dokix>
> Blog RSS Wordpress update
> oddness<http://feedproxy.google.com/%7Er/TheAgileMicroISVBlog/%7E3/mg118P-A8vU/wordpress-update-oddness.html>
>
--
Michael C. Neel (@ViNull)
http://www.ViNull.com
Microsoft MVP & ASPInsider
Do you FeelTheFunc(.com)?