• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Extracting searchwords from a query with Lucene 2.3

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there !

I'm looking for a possibility to extract the words the user searches for from a complex Lucene query.
E.g.: The user types "+title:test +author:daniel". or: "test daniel" or: "title:te* -frank +daniel" etc.
Since Lucene has a powerfull syntax and many features, there are many possibilities the query could look like.
Are there any options to handle this with Lucene classes?

I'll need this for a synonym search. I want to inject synonyms into the query. This meens I'm trying to replace for example the searchquery "test +title:(cat+dog)" with "(test^6 exam trial) +title: ((dog^6 hound) (cat^6 pussycat))" dynamicly. The problem is, the nested expression ( '(' and ')' ) and operators like oder "+" or "-" have to be on the right position after expanding the query.

I'm looking forward to avoid writing an own java-method for this problem...

thanking you in anticipation.

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lucene has synonym/alias support built-in already.
 
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic