Permalink
Browse files

[ignore] update lucene from 4.2.1 to 4.3.1 & add facet jar

svn path=/branches/rangeindex/; revision=18660
  • Loading branch information...
shabanovd committed Jul 7, 2013
1 parent 7d7bf5c commit 7dc9667cd14ce2f5f311a83d60a69ce0bdaef58d
View
@@ -48,8 +48,6 @@
<classpathentry kind="lib" path="lib/core/xmlrpc-client-3.1.3.jar"/>
<classpathentry kind="lib" path="lib/core/xmlrpc-common-3.1.3.jar"/>
<classpathentry kind="lib" path="lib/core/xmlrpc-server-3.1.3.jar"/>
- <classpathentry kind="lib" path="extensions/modules/lib/cssparser-0.9.5.jar"/>
- <classpathentry kind="lib" path="extensions/modules/lib/sac-1.3.jar"/>
<classpathentry kind="lib" path="extensions/expath/lib/http-client-java-0.3.0.jar"/>
<classpathentry kind="lib" path="extensions/exquery/lib/exquery-common-1.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="extensions/exquery/lib/exquery-annotations-common-api-1.0-SNAPSHOT.jar"/>
@@ -107,9 +105,6 @@
<classpathentry kind="lib" path="lib/core/commons-codec-1.7.jar"/>
<classpathentry kind="lib" path="lib/core/gnu-crypto-2.0.1-min.jar"/>
<classpathentry kind="lib" path="lib/optional/commons-net-2.2.jar"/>
- <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-analyzers-3.6.1.jar"/>
- <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-core-3.6.1.jar"/>
- <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-queries-3.6.1.jar"/>
<classpathentry kind="lib" path="tools/jetty/lib/existdb-favicon.jar"/>
<classpathentry kind="lib" path="tools/jetty/lib/jetty-continuation-8.1.9.v20130131.jar"/>
<classpathentry kind="lib" path="tools/jetty/lib/jetty-http-8.1.9.v20130131.jar"/>
@@ -140,5 +135,10 @@
<classpathentry kind="lib" path="lib/optional/httpclient-cache-4.2.3.jar"/>
<classpathentry kind="lib" path="lib/optional/httpcore-4.2.2.jar"/>
<classpathentry kind="lib" path="lib/optional/httpmime-4.2.3.jar"/>
+ <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-analyzers-common-4.3.1.jar"/>
+ <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-core-4.3.1.jar"/>
+ <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-facet-4.3.1.jar"/>
+ <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-queries-4.3.1.jar"/>
+ <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-queryparser-4.3.1.jar"/>
<classpathentry kind="output" path="test/classes"/>
</classpath>
Binary file not shown.
@@ -128,7 +128,6 @@ public String getIndexName() {
return index.getIndexName();
}
- @Override
public QueryRewriter getQueryRewriter(XQueryContext context) {
return null;
}
@@ -623,7 +622,7 @@ public void writeNonXML() {
* @param queryText
* @return search report
*/
- public NodeImpl search(XQueryContext context, final List<String> toBeMatchedURIs, String queryText) throws XPathException {
+ public NodeImpl search(final XQueryContext context, final List<String> toBeMatchedURIs, String queryText) throws XPathException {
NodeImpl report = null;
@@ -633,10 +632,10 @@ public NodeImpl search(XQueryContext context, final List<String> toBeMatchedURIs
searcher = index.getSearcher();
// Get analyzer : to be retrieved from configuration
- final Analyzer searchAnalyzer = new StandardAnalyzer(Version.LUCENE_42);
+ final Analyzer searchAnalyzer = new StandardAnalyzer(Version.LUCENE_43);
// Setup query Version, default field, analyzer
- final QueryParser parser = new QueryParser(Version.LUCENE_42, "", searchAnalyzer);
+ final QueryParser parser = new QueryParser(Version.LUCENE_43, "", searchAnalyzer);
final Query query = parser.parse(queryText);
// extract all used fields from query
@@ -648,32 +647,8 @@ public NodeImpl search(XQueryContext context, final List<String> toBeMatchedURIs
builder.startDocument();
// start root element
-<<<<<<< .working
final int nodeNr = builder.startElement("", "results", "results", null);
-=======
- int nodeNr = builder.startElement("", "results", "results", null);
-
- BitVector processed = new BitVector(searcher.maxDoc());
- // Process result documents
- for (ScoreDoc scoreDoc : results) {
- if (processed.get(scoreDoc.doc))
- continue;
- processed.set(scoreDoc.doc);
-
- Document doc = searcher.doc(scoreDoc.doc);
-
- // Get URI field of document
- String fDocUri = doc.get(FIELD_DOC_URI);
-
- // Get score
- float score = scoreDoc.score;
-
- // Check if document URI has a full match or if a
- // document is in a collection
- if(isDocumentMatch(fDocUri, toBeMatchedURIs)){
->>>>>>> .merge-right.r18646
-
-<<<<<<< .working
+
// Perform actual search
searcher.search(query, new Collector() {
private Scorer scorer;
@@ -697,72 +672,47 @@ public void collect(int docNum) throws IOException {
// Check if document URI has a full match or if a
// document is in a collection
if(isDocumentMatch(fDocUri, toBeMatchedURIs)){
+
+ DocumentImpl storedDoc = null;
+ try {
+ // try to read document to check if user is allowed to access it
+ storedDoc = context.getBroker().getXMLResource(XmldbURI.createInternal(fDocUri), Lock.READ_LOCK);
+ if (storedDoc == null) {
+ return;
+ }
- // setup attributes
- AttributesImpl attribs = new AttributesImpl();
- attribs.addAttribute("", "uri", "uri", "CDATA", fDocUri);
- attribs.addAttribute("", "score", "score", "CDATA", ""+score);
-
- // write element and attributes
- builder.startElement("", "search", "search", attribs);
- for (String field : fields) {
- String[] fieldContent = doc.getValues(field);
- attribs.clear();
- attribs.addAttribute("", "name", "name", "CDATA", field);
- for (String content : fieldContent) {
- List<Offset> offsets = highlighter.getOffsets(content, searchAnalyzer);
- if (offsets != null) {
- builder.startElement("", "field", "field", attribs);
- highlighter.highlight(content, offsets, builder);
- builder.endElement();
+ // setup attributes
+ AttributesImpl attribs = new AttributesImpl();
+ attribs.addAttribute("", "uri", "uri", "CDATA", fDocUri);
+ attribs.addAttribute("", "score", "score", "CDATA", ""+score);
+
+ // write element and attributes
+ builder.startElement("", "search", "search", attribs);
+ for (String field : fields) {
+ String[] fieldContent = doc.getValues(field);
+ attribs.clear();
+ attribs.addAttribute("", "name", "name", "CDATA", field);
+ for (String content : fieldContent) {
+ List<Offset> offsets = highlighter.getOffsets(content, searchAnalyzer);
+ if (offsets != null) {
+ builder.startElement("", "field", "field", attribs);
+ highlighter.highlight(content, offsets, builder);
+ builder.endElement();
+ }
}
}
- }
- builder.endElement();
-
- // clean attributes
- attribs.clear();
-=======
- DocumentImpl storedDoc = null;
- try {
- // try to read document to check if user is allowed to access it
- storedDoc = context.getBroker().getXMLResource(XmldbURI.createInternal(fDocUri), Lock.READ_LOCK);
- if (storedDoc == null) {
- continue;
- }
- // setup attributes
- attribs = new AttributesImpl();
- attribs.addAttribute("", "uri", "uri", "CDATA", fDocUri);
- attribs.addAttribute("", "score", "score", "CDATA", ""+score);
-
- // write element and attributes
- builder.startElement("", "search", "search", attribs);
- for (String field : fields) {
- String[] fieldContent = doc.getValues(field);
+ builder.endElement();
+
+ // clean attributes
attribs.clear();
- attribs.addAttribute("", "name", "name", "CDATA", field);
- for (String content : fieldContent) {
- List<Offset> offsets = highlighter.getOffsets(content, searchAnalyzer);
- if (offsets != null) {
- builder.startElement("", "field", "field", attribs);
- highlighter.highlight(content, offsets, builder);
- builder.endElement();
- }
+ } catch (PermissionDeniedException e) {
+ // not allowed to read the document: ignore the match.
+ } finally {
+ if (storedDoc != null) {
+ storedDoc.getUpdateLock().release(Lock.READ_LOCK);
}
}
- builder.endElement();
-
- // clean attributes
- attribs.clear();
- } catch (PermissionDeniedException e) {
- // not allowed to read the document: ignore the match.
- } finally {
- if (storedDoc != null) {
- storedDoc.getUpdateLock().release(Lock.READ_LOCK);
- }
->>>>>>> .merge-right.r18646
}
-<<<<<<< .working
}
@Override
@@ -776,11 +726,6 @@ public boolean acceptsDocsOutOfOrder() {
}
});
-=======
- }
- }
-
->>>>>>> .merge-right.r18646
// finish root element
builder.endElement();
@@ -1,13 +1,19 @@
package org.exist.indexing.lucene.analyzers;
import org.apache.lucene.analysis.*;
+import org.apache.lucene.analysis.core.LowerCaseFilter;
+import org.apache.lucene.analysis.core.StopAnalyzer;
+import org.apache.lucene.analysis.core.StopFilter;
+import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilter;
import org.apache.lucene.analysis.standard.StandardFilter;
import org.apache.lucene.analysis.standard.StandardTokenizer;
+import org.apache.lucene.analysis.util.CharArraySet;
+import org.apache.lucene.analysis.util.StopwordAnalyzerBase;
+import org.apache.lucene.analysis.util.WordlistLoader;
import org.apache.lucene.util.Version;
import java.io.IOException;
import java.io.Reader;
-import java.util.Set;
/**
* A copy of StandardAnalyzer using an additional ASCIIFoldingFilter to
@@ -28,15 +34,15 @@
/** An unmodifiable set containing some common English words that are usually not
useful for searching. */
- public static final Set<?> STOP_WORDS_SET = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
+ public static final CharArraySet STOP_WORDS_SET = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
/** Builds an analyzer with the given stop words.
* @param matchVersion Lucene version to match See {@link
* <a href="#version">above</a>}
* @param stopWords stop words */
- public NoDiacriticsStandardAnalyzer(Version matchVersion, Set<?> stopWords) {
+ public NoDiacriticsStandardAnalyzer(Version matchVersion, CharArraySet stopWords) {
super(matchVersion, stopWords);
- replaceInvalidAcronym = matchVersion.onOrAfter(Version.LUCENE_24);
+ replaceInvalidAcronym = matchVersion.onOrAfter(Version.LUCENE_43);
}
/** Builds an analyzer with the default stop words ({@link
@@ -78,17 +84,18 @@ public int getMaxTokenLength() {
protected TokenStreamComponents createComponents(final String fieldName, final Reader reader) {
final StandardTokenizer src = new StandardTokenizer(matchVersion, reader);
src.setMaxTokenLength(maxTokenLength);
- src.setReplaceInvalidAcronym(replaceInvalidAcronym);
+// src.setReplaceInvalidAcronym(replaceInvalidAcronym);
TokenStream tok = new StandardFilter(matchVersion, src);
tok = new ASCIIFoldingFilter(tok);
tok = new LowerCaseFilter(matchVersion, tok);
tok = new StopFilter(matchVersion, tok, stopwords);
- return new TokenStreamComponents(src, tok) {
- @Override
- protected boolean reset(final Reader reader) throws IOException {
- src.setMaxTokenLength(NoDiacriticsStandardAnalyzer.this.maxTokenLength);
- return super.reset(reader);
- }
- };
+ return new TokenStreamComponents(src, tok);
+// {
+// @Override
+// protected boolean reset(final Reader reader) throws IOException {
+// src.setMaxTokenLength(NoDiacriticsStandardAnalyzer.this.maxTokenLength);
+// return super.reset(reader);
+// }
+// };
}
}

0 comments on commit 7dc9667

Please sign in to comment.