Hi! Another option for a term query would be an analyzer, which creates keywords from paths, building them from every neighbouring pair in the path. So you could query for paths anywhere in the hierarchy, and you don't have to start from the top level hierarchy like in the approach mentioned below.
Top/World/Poland/Abc -> "Top-World", "World-Poland", "Poland-Abc" So you could search for World/Poland too, because the analyzer would create "World-Poland" from the query, which matches one of the above terms. World/Poland/Abc ( -> "World-Poland", "Poland-Abc") would result in a better relevance for above example. regards, Mathias -- Mathias Lux http://www.semanticmetadata.net > -----Ursprüngliche Nachricht----- > Von: kieran [mailto:[EMAIL PROTECTED] > Gesendet: Mittwoch, 15. März 2006 14:41 > An: java-user@lucene.apache.org > Betreff: Re: Searching in paths > > Alternatively, you could examine each path, and index each of its > "parent" paths (perhaps in a field named "parentPath"). > i.e. > Top/World/Poland/Abc > would result in the following three values being indexed: > Top > Top/World > Top/World/Poland > You can then use a TermQuery instead of a PrefixQuery. > For instance, to perform the query that you suggested, you > would code it > as follows: > > say, cat="Top/World/Poland" > > Query query1 = null; > if(cat!=""){ > Term term = new Term("category",cat); > query1 = new TermQuery(term); > Hits hits = is.search(query1); > } > > NB as an aside, unless "cat" is interned, (cat!="") will > ALWAYS return > true. But you probably knew that ;-) > > Kieran > > Java Programmer wrote: > > Reply to myself hate this :( > > > > What about such solution: > > Split path like string into smaller tokens and index them > as seperate words eg: > > #Top/World/Poland/# #Top/World/# #Top/# > > so if I ask about word #Top/# I will get all the results for this > > category, without making so many boolean queries. > > > > Is there a better solution for my problem? > > > > Best Regards, > > Adr > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]