java - Need to run Lucene Analyzer offline from servlet -
this might quite meaty question problem have spring servlet used real-time searching. need strip out lucene analyzer runs offline , called servlet everytime query comes in it, rather having analyzer within servlet. however, don't quite know how this, , call analyzer service servlet. can point me in right direction?
at moment, have this:
ramdirectory ramdirectory = new ramdirectory(); standardanalyzer analyzer = new standardanalyzer(version.lucene_31); indexwriterconfig config = new indexwriterconfig(version.lucene_31, analyzer); indexwriter indexwriter = new indexwriter(ramdirectory, config); document document = new document(); // test data document.add(new field("firstname", "john", field.store.yes, field.index.analyzed)); document.add(new field("occupation", "engineer", field.store.yes, field.index.analyzed)); document.add(new field("firstname", "mary", field.store.yes, field.index.analyzed)); document.add(new field("occupation", "field engineer", field.store.yes, field.index.analyzed)); document.add(new field("firstname", "jamie", field.store.yes, field.index.analyzed)); document.add(new field("occupation", "primary teacher", field.store.yes, field.index.analyzed)); // end test data indexwriter.adddocument(document); indexwriter.optimize(); indexwriter.close(); indexsearcher indexsearcher = new indexsearcher(ramdirectory); string[] fields = {"firstname", "occupation"}; multifieldqueryparser parser = new multifieldqueryparser(null, fields, analyzer); query query = parser.parse(searchquery); // parsing of results here thanks.
why find current design poor in terms of performance? problem running exactly?
i believe you're looking form of inter-process communications. 2 options come mind are:
synchronous: offload processing server (http or plain tcp) envelopes lucene , responds query results. useful scaling system since lets separate lucene machine, other that, there no immediate performance gains.
asynchronous: offload queue (e.g. zeromq) other process listens on, runs lucene, returns result through other queue. less advantageous if need respond user on other end, , in case hard implement java servlets (though if knows otherwise, i'd love hear it).
Comments
Post a Comment