Java – how to use in Net?
Lucene is a good search engine, but Net version is the official JAVA version (the latest stable. Net version is 2.0, but the latest Java Lucene version is 2.4, which has more functions)
How do you solve this problem?
resolvent
Solution
I found a way that is amazing to work: from Java Create a. Jar file NET DLL! Ikvm can be obtained by downloading Lucene Jar file and run:
ikvmc -target:library <path-to-lucene.jar>
It generates a Net DLL, as follows: lucene-core-2.4 0.dll
Then you can reference this DLL from your project. You're good to go! You will need some Java types, so also refer to ikvm OpenJDK. ClassLibrary. dll. Your code might look like this:
QueryParser parser = new QueryParser("field1",analyzer); java.util.Map boosts = new java.util.HashMap(); boosts.put("field1",new java.lang.Float(1.0)); boosts.put("field2",new java.lang.Float(10.0)); MultiFieldQueryParser multiParser = new MultiFieldQueryParser (new string[] { "field1","field2" },analyzer,boosts); multiParser.setDefaultOperator(QueryParser.Operator.OR); Query query = multiParser.parse("ABC"); Hits hits = isearcher.search(query);
I never knew you could easily combine java with Net interoperability The best point is that c# and Java are "almost" source compatible (Lucene example) Just use console Writeln replaces system Out :).
=======
Update: when building a library like Lucene highlighter, make sure to reference the core assembly (otherwise you will receive a warning about missing classes) So the highlighter is built like this:
ikvmc -target:library lucene-Highlighter-2.4.0.jar -r:lucene-core-2.4.0.dll
The above is the Java collected by programming house for you - how to use it in Net? I hope this article can help you solve Java - how to Net? Program development problems encountered.
If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.