Author: Maital Ashkenazi
Date: 2010-07-20 07:07:17 -0700 (Tue, 20 Jul 2010)
New Revision: 20969
Added:
csplugins/trunk/soc/maital/EnhancedSearch2/.classpath
csplugins/trunk/soc/maital/EnhancedSearch2/.project
csplugins/trunk/soc/maital/EnhancedSearch2/EnhancedSearch.jar
csplugins/trunk/soc/maital/EnhancedSearch2/lib/lucene-core-3.0.1.jar
Removed:
csplugins/trunk/soc/maital/EnhancedSearch2/lib/lucene-core-2.9.0.jar
Modified:
csplugins/trunk/soc/maital/EnhancedSearch2/build.xml
csplugins/trunk/soc/maital/EnhancedSearch2/plugin.props
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchIndex.java
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchPanel.java
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchQuery.java
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/IndexAndSearchTask.java
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/util/CustomMultiFieldQueryParser.java
Log:
New version, based on Lucene 3.0.1.
Code was fixed to match Lucene API changes. NumberField class handles numeric
attributes ==> no need to use NumberTools and NumberUtils.
Added: csplugins/trunk/soc/maital/EnhancedSearch2/.classpath
===================================================================
--- csplugins/trunk/soc/maital/EnhancedSearch2/.classpath
(rev 0)
+++ csplugins/trunk/soc/maital/EnhancedSearch2/.classpath 2010-07-20
14:07:17 UTC (rev 20969)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="/cytoscape/cytoscape.jar"/>
+ <classpathentry kind="lib"
path="/cytoscape/plugins/core/quick_find.jar"/>
+ <classpathentry kind="lib" path="/cytoscape/lib/cytoscape-task.jar"/>
+ <classpathentry kind="lib" path="/cytoscape/lib/giny.jar"/>
+ <classpathentry kind="lib" path="lib/lucene-core-3.0.1.jar"/>
+ <classpathentry kind="lib" path="/cytoscape/lib/junit.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: csplugins/trunk/soc/maital/EnhancedSearch2/.project
===================================================================
--- csplugins/trunk/soc/maital/EnhancedSearch2/.project
(rev 0)
+++ csplugins/trunk/soc/maital/EnhancedSearch2/.project 2010-07-20 14:07:17 UTC
(rev 20969)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>EnhancedSearch2</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: csplugins/trunk/soc/maital/EnhancedSearch2/EnhancedSearch.jar
===================================================================
(Binary files differ)
Property changes on:
csplugins/trunk/soc/maital/EnhancedSearch2/EnhancedSearch.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: csplugins/trunk/soc/maital/EnhancedSearch2/build.xml
===================================================================
--- csplugins/trunk/soc/maital/EnhancedSearch2/build.xml 2010-07-19
21:50:14 UTC (rev 20968)
+++ csplugins/trunk/soc/maital/EnhancedSearch2/build.xml 2010-07-20
14:07:17 UTC (rev 20969)
@@ -91,11 +91,6 @@
<java classname="cytoscape.CyMain" classpathref="compile.classpath"
fork="true" maxmemory="1000M">
<arg line="-p ${cytoscape.dir}/plugins/core"/>
- <!--arg line="-N ${testData.dir}/network.sif -n
${testData.dir}/AGI.NA -n ${testData.dir}/Chromosome.NA
- -n ${testData.dir}/DesiccationResponse.NA -n
${testData.dir}/GeneTitle.NA
- -n ${testData.dir}/GOBiologicalProcess.NA -n
${testData.dir}/GOCellularComponent.NA
- -n ${testData.dir}/GOMolecularFunction.NA -e
${testData.dir}/interaction.EA
- -e ${testData.dir}/weight.EA -p
${cytoscape.dir}/plugins/core"/-->
</java>
</target>
Deleted: csplugins/trunk/soc/maital/EnhancedSearch2/lib/lucene-core-2.9.0.jar
===================================================================
(Binary files differ)
Added: csplugins/trunk/soc/maital/EnhancedSearch2/lib/lucene-core-3.0.1.jar
===================================================================
(Binary files differ)
Property changes on:
csplugins/trunk/soc/maital/EnhancedSearch2/lib/lucene-core-3.0.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: csplugins/trunk/soc/maital/EnhancedSearch2/plugin.props
===================================================================
--- csplugins/trunk/soc/maital/EnhancedSearch2/plugin.props 2010-07-19
21:50:14 UTC (rev 20968)
+++ csplugins/trunk/soc/maital/EnhancedSearch2/plugin.props 2010-07-20
14:07:17 UTC (rev 20969)
@@ -13,10 +13,10 @@
pluginDescription=Perform search on multiple attribute fields using logical
operators and wildcards. Locate nodes and edges of interest based on their
attributes and highlight them on the network. The simple query syntax is
detailed in the URL below.
# Plugin version number, this must be two numbers separated by a decimlal.
Ex. 0.2, 14.03
-pluginVersion=1.1
+pluginVersion=1.2
# Compatible Cytoscape version
-cytoscapeVersion=2.5,2.6
+cytoscapeVersion=2.5,2.6,2.7,2.8
# Category, use one of the categories listed on the website or create your own
pluginCategory=Analysis
@@ -28,7 +28,7 @@
# List of authors. Note each author and institution pair are separated by a :
(colon)
# each additional author institution pair must be separated from other pairs
bye a ; (semicolon)
-pluginAuthorsIntsitutions=Maital Ashkenazi:HUJI
+pluginAuthorsIntsitutions=Maital Ashkenazi:Evogene
# Date this plugin/plugin version was released
-releaseDate=January 1, 2008
\ No newline at end of file
+releaseDate=July 20, 2010
\ No newline at end of file
Modified:
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchIndex.java
===================================================================
---
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchIndex.java
2010-07-19 21:50:14 UTC (rev 20968)
+++
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchIndex.java
2010-07-20 14:07:17 UTC (rev 20969)
@@ -44,23 +44,23 @@
import cytoscape.CyNetwork;
import cytoscape.data.CyAttributes;
-import csplugins.quickfind.util.CyAttributesUtil;
import csplugins.enhanced.search.util.EnhancedSearchUtils;
-import csplugins.enhanced.search.util.NumberUtils;
+import csplugins.quickfind.util.CyAttributesUtil;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.NumericField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.document.Document;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.document.NumberTools;
public class EnhancedSearchIndex {
public static final String INDEX_FIELD = "id";
-
public static final int MAX_FIELD_LENGTH = 50000;
+ private static StandardAnalyzer analyzer = new
StandardAnalyzer(Version.LUCENE_30);
RAMDirectory idx;
@@ -74,10 +74,10 @@
private void BuildIndex(RAMDirectory idx, CyNetwork network) {
try {
- // Make a writer to create the index
- IndexWriter writer = new IndexWriter(idx, new
StandardAnalyzer(),
- true);
+ // Make a writer to create the index
+ IndexWriter writer = new IndexWriter(idx, analyzer,
true, IndexWriter.MaxFieldLength.UNLIMITED);
+
// Set the number of terms to be indexed for a field.
// writer.setMaxFieldLength(MAX_FIELD_LENGTH);
@@ -125,7 +125,7 @@
Document doc = new Document();
doc.add(new Field(INDEX_FIELD, identifier, Field.Store.YES,
- Field.Index.TOKENIZED));
+ Field.Index.ANALYZED));
String[] attrNameArray = attributes.getAttributeNames();
for (int i = 0; i < attrNameArray.length; i++) {
@@ -142,28 +142,23 @@
byte valueType = attributes.getType(attrName);
if (valueType == CyAttributes.TYPE_BOOLEAN) {
- String attrValue =
attributes.getBooleanAttribute(
- identifier,
attrName).toString();
+ String attrValue =
attributes.getBooleanAttribute(identifier, attrName).toString();
doc.add(new Field(attrIndexingName,
attrValue,
- Field.Store.NO,
Field.Index.UN_TOKENIZED));
+ Field.Store.NO,
Field.Index.NOT_ANALYZED));
} else if (valueType ==
CyAttributes.TYPE_INTEGER) {
- String attrValue =
NumberTools.longToString(attributes.getIntegerAttribute(
- identifier, attrName));
- doc.add(new Field(attrIndexingName,
attrValue,
- Field.Store.NO,
Field.Index.UN_TOKENIZED));
+ Integer attrValue =
attributes.getIntegerAttribute(identifier, attrName);
+ doc.add(new
NumericField(attrIndexingName).setIntValue(attrValue));
} else if (valueType ==
CyAttributes.TYPE_FLOATING) {
- String attrValue =
NumberUtils.double2sortableStr(attributes.getDoubleAttribute(
- identifier, attrName));
- doc.add(new Field(attrIndexingName,
attrValue,
- Field.Store.NO,
Field.Index.UN_TOKENIZED));
+ Double attrValue =
attributes.getDoubleAttribute(identifier, attrName);
+ doc.add(new
NumericField(attrIndexingName).setDoubleValue(attrValue));
} else if (valueType ==
CyAttributes.TYPE_STRING) {
String attrValue =
attributes.getStringAttribute(
identifier, attrName);
doc.add(new Field(attrIndexingName,
attrValue,
- Field.Store.NO,
Field.Index.TOKENIZED));
+ Field.Store.NO,
Field.Index.ANALYZED));
} else if (valueType ==
CyAttributes.TYPE_SIMPLE_LIST
|| valueType ==
CyAttributes.TYPE_SIMPLE_MAP) {
@@ -179,7 +174,7 @@
String attrValue =
valueList[j];
doc.add(new
Field(attrIndexingName, attrValue,
-
Field.Store.NO, Field.Index.TOKENIZED));
+
Field.Store.NO, Field.Index.ANALYZED));
}
}
} else if (valueType ==
CyAttributes.TYPE_COMPLEX) {
Modified:
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchPanel.java
===================================================================
---
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchPanel.java
2010-07-19 21:50:14 UTC (rev 20968)
+++
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchPanel.java
2010-07-20 14:07:17 UTC (rev 20969)
@@ -70,7 +70,7 @@
private JLabel label;
- private static final String ESP_LABEL = "ESP 2.9.0: ";
+ private static final String ESP_LABEL = "ESP 3.0.1: ";
private static final String SEARCH_MENU_ITEM = "Search";
Modified:
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchQuery.java
===================================================================
---
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchQuery.java
2010-07-19 21:50:14 UTC (rev 20968)
+++
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchQuery.java
2010-07-20 14:07:17 UTC (rev 20969)
@@ -40,12 +40,15 @@
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.search.HitCollector;
+import org.apache.lucene.search.Collector;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IndexReader;
import csplugins.enhanced.search.util.EnhancedSearchUtils;
import csplugins.enhanced.search.util.CustomMultiFieldQueryParser;
@@ -54,10 +57,9 @@
public class EnhancedSearchQuery {
private IdentifiersCollector hitCollector = null;
-
private RAMDirectory idx;
-
private Searcher searcher;
+ private static StandardAnalyzer analyzer = new
StandardAnalyzer(Version.LUCENE_30);
public EnhancedSearchQuery(RAMDirectory index) {
idx = index;
@@ -91,7 +93,7 @@
// Build a Query object.
// CustomMultiFieldQueryParser is used to support range queries
on numerical attribute fields.
- CustomMultiFieldQueryParser queryParser = new
CustomMultiFieldQueryParser(attFields, new StandardAnalyzer());
+ CustomMultiFieldQueryParser queryParser = new
CustomMultiFieldQueryParser(Version.LUCENE_30, attFields, analyzer);
try {
// Execute query
@@ -137,7 +139,7 @@
}
-class IdentifiersCollector extends HitCollector {
+class IdentifiersCollector extends Collector {
public static final String INDEX_FIELD = "id";
@@ -149,7 +151,7 @@
this.searcher = searcher;
}
- public void collect(int id, float score) {
+ public void collect(int id) {
try {
Document doc = searcher.doc(id);
String currID = doc.get(INDEX_FIELD);
@@ -167,4 +169,22 @@
return hitsIdentifiers;
}
+ @Override
+ public boolean acceptsDocsOutOfOrder() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setNextReader(IndexReader arg0, int arg1) throws
IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setScorer(Scorer arg0) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified:
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/IndexAndSearchTask.java
===================================================================
---
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/IndexAndSearchTask.java
2010-07-19 21:50:14 UTC (rev 20968)
+++
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/IndexAndSearchTask.java
2010-07-20 14:07:17 UTC (rev 20969)
@@ -66,7 +66,7 @@
* @param query
* Query string.
*/
- IndexAndSearchTask(CyNetwork network, String query) {
+ public IndexAndSearchTask(CyNetwork network, String query) {
this.network = network;
this.query = query;
}
Modified:
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/util/CustomMultiFieldQueryParser.java
===================================================================
---
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/util/CustomMultiFieldQueryParser.java
2010-07-19 21:50:14 UTC (rev 20968)
+++
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/util/CustomMultiFieldQueryParser.java
2010-07-20 14:07:17 UTC (rev 20969)
@@ -1,4 +1,3 @@
-
/*
Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
@@ -41,56 +40,52 @@
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.document.NumberTools;
-import org.apache.lucene.search.RangeQuery;
-import org.apache.lucene.index.Term;
+import org.apache.lucene.search.NumericRangeQuery;
+import org.apache.lucene.util.Version;
import csplugins.enhanced.search.util.AttributeFields;
-import csplugins.enhanced.search.util.NumberUtils;
import cytoscape.data.CyAttributes;
-
/**
- * This custom MultiFieldQueryParser is used to parse queries containing
numerical values.
- * Lucene treats all attribute field values as strings. During indexing,
numerical values were transformed
- * into structured strings preserving their numerical sorting order. Now,
numerical values in query
- * should also be transformed so they can be properly compared to the values
stored in the index.
+ * This custom MultiFieldQueryParser is used to parse queries containing
numerical values. Lucene treats all attribute field values as strings. During
indexing, numerical values were transformed into
+ * structured strings preserving their numerical sorting order. Now, numerical
values in query should also be transformed so they can be properly compared to
the values stored in the index.
*/
public class CustomMultiFieldQueryParser extends MultiFieldQueryParser {
private AttributeFields attrFields;
- public CustomMultiFieldQueryParser(AttributeFields attrFields,
- Analyzer analyzer) {
- super(attrFields.getFields(), analyzer);
+ public CustomMultiFieldQueryParser(Version matchVersion,
AttributeFields attrFields, Analyzer analyzer) {
+ super(Version.LUCENE_30, attrFields.getFields(), analyzer);
this.attrFields = attrFields;
}
- protected Query getFieldQuery(String field, String queryText)
- throws ParseException {
-
+ protected Query getFieldQuery(String field, String queryText) throws
ParseException {
+
if (attrFields.getType(field) == CyAttributes.TYPE_INTEGER) {
try {
+ // Workaround: The commented statement below
won't return the desired
+ // search result, but inclusive range query
does.
+ // return super.getFieldQuery(field, queryText);
int num1 = Integer.parseInt(queryText);
- return super.getFieldQuery(field, NumberTools
- .longToString(num1));
+ Query q = NumericRangeQuery.newIntRange(field,
num1, num1, true, true);
+ return q;
} catch (NumberFormatException e) {
// Do nothing. When using a
MultiFieldQueryParser, queryText is
// searched in each one of the fields. This
exception occurs
// when trying to convert non-numeric queryText
into numeric.
// throw new ParseException(e.getMessage());
+ System.out.println("Exception");
}
} else if (attrFields.getType(field) ==
CyAttributes.TYPE_FLOATING) {
try {
- double num1 = Double.parseDouble(queryText);
// Workaround: The commented statement below
won't return the desired
// search result, but inclusive range query
does.
// return super.getFieldQuery(field, NumberUtils
// .double2sortableStr(num1));
- return new RangeQuery(new Term(field,
NumberUtils
- .double2sortableStr(num1)), new
Term(field, NumberUtils
- .double2sortableStr(num1)),
true);
+ double num1 = Double.parseDouble(queryText);
+ Query q =
NumericRangeQuery.newDoubleRange(field, num1, num1, true, true);
+ return q;
} catch (NumberFormatException e) {
// Do nothing. When using a
MultiFieldQueryParser, queryText is
// searched in each one of the fields. This
exception occurs
@@ -98,13 +93,11 @@
// throw new ParseException(e.getMessage());
}
}
-
+
return super.getFieldQuery(field, queryText);
}
- protected Query getRangeQuery(String field, String part1, String part2,
- boolean inclusive) throws ParseException {
-
+ protected Query getRangeQuery(String field, String part1, String part2,
boolean inclusive) throws ParseException {
// a workaround to avoid a TooManyClauses exception.
// Temporary until RangeFilter is implemented.
BooleanQuery.setMaxClauseCount(5120); // 5 * 1024
@@ -113,9 +106,8 @@
try {
int num1 = Integer.parseInt(part1);
int num2 = Integer.parseInt(part2);
- return new RangeQuery(new Term(field,
NumberTools
- .longToString(num1)), new
Term(field, NumberTools
- .longToString(num2)),
inclusive);
+ Query q = NumericRangeQuery.newIntRange(field,
num1, num2, inclusive, inclusive);
+ return q;
} catch (NumberFormatException e) {
throw new ParseException(e.getMessage());
}
@@ -124,9 +116,8 @@
try {
double num1 = Double.parseDouble(part1);
double num2 = Double.parseDouble(part2);
- return new RangeQuery(new Term(field,
NumberUtils
- .double2sortableStr(num1)), new
Term(field, NumberUtils
- .double2sortableStr(num2)),
inclusive);
+ Query q =
NumericRangeQuery.newDoubleRange(field, num1, num2, inclusive, inclusive);
+ return q;
} catch (NumberFormatException e) {
throw new ParseException(e.getMessage());
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.