lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1002456 - in /lucene/sandbox/luke/src/org/apache/lucene/luke: core/TableComparator.java ui/DocumentsTab.java ui/OverviewTab.bxml ui/OverviewTab.java ui/SearchTab.bxml ui/SearchTab.java
Date Wed, 29 Sep 2010 03:34:00 GMT
Author: markrmiller
Date: Wed Sep 29 03:33:59 2010
New Revision: 1002456

URL: http://svn.apache.org/viewvc?rev=1002456&view=rev
Log:
initial hookup of parsed and rewritten query displays - a little more futzing trying to get
table sorting working

Modified:
    lucene/sandbox/luke/src/org/apache/lucene/luke/core/TableComparator.java
    lucene/sandbox/luke/src/org/apache/lucene/luke/ui/DocumentsTab.java
    lucene/sandbox/luke/src/org/apache/lucene/luke/ui/OverviewTab.bxml
    lucene/sandbox/luke/src/org/apache/lucene/luke/ui/OverviewTab.java
    lucene/sandbox/luke/src/org/apache/lucene/luke/ui/SearchTab.bxml
    lucene/sandbox/luke/src/org/apache/lucene/luke/ui/SearchTab.java

Modified: lucene/sandbox/luke/src/org/apache/lucene/luke/core/TableComparator.java
URL: http://svn.apache.org/viewvc/lucene/sandbox/luke/src/org/apache/lucene/luke/core/TableComparator.java?rev=1002456&r1=1002455&r2=1002456&view=diff
==============================================================================
--- lucene/sandbox/luke/src/org/apache/lucene/luke/core/TableComparator.java (original)
+++ lucene/sandbox/luke/src/org/apache/lucene/luke/core/TableComparator.java Wed Sep 29 03:33:59
2010
@@ -40,7 +40,7 @@ public class TableComparator implements 
     
     SortDirection sortDirection = tableView.getSort().get("name");
     
-    result *= (sortDirection == SortDirection.ASCENDING ? 1 : -1);
+    result *= (sortDirection == SortDirection.DESCENDING ? 1 : -1);
     
     return result * -1;
   }

Modified: lucene/sandbox/luke/src/org/apache/lucene/luke/ui/DocumentsTab.java
URL: http://svn.apache.org/viewvc/lucene/sandbox/luke/src/org/apache/lucene/luke/ui/DocumentsTab.java?rev=1002456&r1=1002455&r2=1002456&view=diff
==============================================================================
--- lucene/sandbox/luke/src/org/apache/lucene/luke/ui/DocumentsTab.java (original)
+++ lucene/sandbox/luke/src/org/apache/lucene/luke/ui/DocumentsTab.java Wed Sep 29 03:33:59
2010
@@ -34,7 +34,10 @@ import org.apache.lucene.luke.core.Index
 import org.apache.lucene.luke.core.Util;
 import org.apache.lucene.luke.core.decoders.Decoder;
 import org.apache.lucene.luke.ui.LukeWindow.LukeMediator;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Similarity;
+import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.util.BytesRef;
 import org.apache.pivot.beans.BXML;
 import org.apache.pivot.beans.Bindable;
@@ -93,7 +96,7 @@ public class DocumentsTab extends TableP
   private DocsAndPositionsEnum td;
   
   private String fld;
-  private Term lastShownTerm;
+  private Term lastTerm;
   private IndexReader ir;
   private java.util.List<String> indexFields;
   private IndexInfo idxInfo;
@@ -411,7 +414,7 @@ public class DocumentsTab extends TableP
   
   public void showFirstTermDoc() {
     
-    if (lastShownTerm == null) return;
+    if (lastTerm == null) return;
     if (ir == null) {
       // TODO:
       // showStatus(resources.get("documentsTab_noOrClosedIndex"));
@@ -423,7 +426,7 @@ public class DocumentsTab extends TableP
       public Object execute() throws TaskExecutionException {
         try {
           DocsAndPositionsEnum td = MultiFields.getTermPositionsEnum(ir, null,
-              lastShownTerm.field(), lastShownTerm.bytes());
+              lastTerm.field(), lastTerm.bytes());
           td.nextDoc();
           tdNum.setText("1");
           DocumentsTab.this.td = td;
@@ -461,7 +464,7 @@ public class DocumentsTab extends TableP
   }
   
   public void showNextTermDoc() {
-    if (lastShownTerm == null) return;
+    if (lastTerm == null) return;
     if (ir == null) {
       // TODO:
       // showStatus(MSG_NOINDEX);
@@ -531,7 +534,7 @@ public class DocumentsTab extends TableP
       return;
     }
     
-    lastShownTerm = t;
+    lastTerm = t;
     
     fieldsList.setSelectedItem(t.field());
     Decoder dec = lukeMediator.getDecoders().get(t.field());
@@ -560,7 +563,7 @@ public class DocumentsTab extends TableP
       // setColor(rawText, "foreground", Color.BLACK);
     }
     
-    lastShownTerm = t;
+    lastTerm = t;
     // putProperty(fText, "decText", s);
     
     td = null;
@@ -757,4 +760,73 @@ public class DocumentsTab extends TableP
     }
   }
   
+  public void showAllTermDoc() {
+    final IndexReader ir = lukeMediator.getIndexInfo().getReader();
+    if (ir == null) {
+      // TODO:
+      //showStatus("MSG_NOINDEX");
+      return;
+    }
+    //Object tabpane = find("maintpane");
+    //setInteger(tabpane, "selected", 2);
+    //Object qField = find("qField");
+    //setString(qField, "text", t.field() + ":" + t.text());
+    //Object qFieldParsed = find("qFieldParsed");
+    //Object ckScoreRes = find("ckScoreRes");
+    //Object ckOrderRes = find("ckOrderRes");
+    //Object cntRepeat = find("cntRepeat");
+    //final boolean scoreRes = getBoolean(ckScoreRes, "selected");
+    //final boolean orderRes = getBoolean(ckOrderRes, "selected");
+    //final int repeat = Integer.parseInt(getString(cntRepeat, "text"));
+    final Query q = new TermQuery(lastTerm);
+    //parsedQueryLabel.setText(q.toString());
+    Task<Object> showAllTermDocTask = new Task<Object>() {
+      
+      @Override
+      public Object execute() throws TaskExecutionException {
+        IndexSearcher is = null;
+        try {
+          is = new IndexSearcher(ir);
+          //Object sTable = find("sTable");
+          //removeAll(sTable);
+          //AllHitsCollector ahc = new AllHitsCollector(orderRes, scoreRes);
+         // _search(q, is, ahc, sTable, repeat);
+        } catch (Exception e) {
+          e.printStackTrace();
+          // TODO:
+          //errorMsg(e.getMessage());
+        } finally {
+          if (is != null) try {
+            is.close();
+          } catch (Exception e1) {}
+        }     
+        return null;
+      }
+    };
+    if (lukeMediator.isSlowAccess()) {
+      
+      TaskListener<Object> taskListener = new TaskListener<Object>() {
+        @Override
+        public void taskExecuted(Task<Object> task) {
+          // ai.setActive(false);
+          // lukeWindow.setEnabled(true);
+        }
+        
+        @Override
+        public void executeFailed(Task<Object> task) {
+          // ai.setActive(false);
+          // lukeWindow.setEnabled(true);
+        }
+      };
+      
+      showAllTermDocTask.execute(new TaskAdapter<Object>(taskListener));
+    } else {
+      try {
+        showAllTermDocTask.execute();
+      } catch (TaskExecutionException e) {
+        throw new RuntimeException(e);
+      }
+    }
+  }
+  
 }

Modified: lucene/sandbox/luke/src/org/apache/lucene/luke/ui/OverviewTab.bxml
URL: http://svn.apache.org/viewvc/lucene/sandbox/luke/src/org/apache/lucene/luke/ui/OverviewTab.bxml?rev=1002456&r1=1002455&r2=1002456&view=diff
==============================================================================
--- lucene/sandbox/luke/src/org/apache/lucene/luke/ui/OverviewTab.bxml (original)
+++ lucene/sandbox/luke/src/org/apache/lucene/luke/ui/OverviewTab.bxml Wed Sep 29 03:33:59
2010
@@ -28,7 +28,7 @@
 												<Label text="%overviewTab_indexPath"
 													styles="{font:{bold:true},backgroundColor:'#dce0e7',padding:2}" />
 												<Label bxml:id="iPath" text="?"
-													styles="{backgroundColor:11,padding:2}" />
+													styles="{backgroundColor:'#fcfdfd',padding:2}" />
 											</TablePane.Row>
 											<TablePane.Row height="-1">
 												<Label text="%overviewTab_indexCodec"

Modified: lucene/sandbox/luke/src/org/apache/lucene/luke/ui/OverviewTab.java
URL: http://svn.apache.org/viewvc/lucene/sandbox/luke/src/org/apache/lucene/luke/ui/OverviewTab.java?rev=1002456&r1=1002455&r2=1002456&view=diff
==============================================================================
--- lucene/sandbox/luke/src/org/apache/lucene/luke/ui/OverviewTab.java (original)
+++ lucene/sandbox/luke/src/org/apache/lucene/luke/ui/OverviewTab.java Wed Sep 29 03:33:59
2010
@@ -42,6 +42,7 @@ import org.apache.pivot.collections.List
 import org.apache.pivot.collections.Map;
 import org.apache.pivot.collections.Sequence;
 import org.apache.pivot.serialization.SerializationException;
+import org.apache.pivot.util.Filter;
 import org.apache.pivot.util.Resources;
 import org.apache.pivot.util.concurrent.Task;
 import org.apache.pivot.util.concurrent.TaskExecutionException;
@@ -57,6 +58,13 @@ import org.apache.pivot.wtk.Spinner;
 import org.apache.pivot.wtk.SplitPane;
 import org.apache.pivot.wtk.TablePane;
 import org.apache.pivot.wtk.TableView;
+import org.apache.pivot.wtk.TableView.CellRenderer;
+import org.apache.pivot.wtk.TableView.Column;
+import org.apache.pivot.wtk.TableView.HeaderDataRenderer;
+import org.apache.pivot.wtk.TableView.RowEditor;
+import org.apache.pivot.wtk.TableView.SelectMode;
+import org.apache.pivot.wtk.TableViewColumnListener;
+import org.apache.pivot.wtk.TableViewListener;
 import org.apache.pivot.wtk.TableViewSortListener;
 import org.apache.pivot.wtk.TaskAdapter;
 
@@ -486,7 +494,8 @@ public class OverviewTab extends SplitPa
     percentFormat.setMaximumFractionDigits(2);
     // // sort by names now
     final List<Map<String,String>> tableData = new ArrayList<Map<String,String>>();
-    
+    tableData.setComparator(new TableComparator(fieldsTable));
+
     fieldsTable.getTableViewSortListeners().add(new TableViewSortListener(){
 
       @Override
@@ -508,13 +517,13 @@ public class OverviewTab extends SplitPa
       public void sortRemoved(TableView tableView, String columnName,
           SortDirection sortDirection) {
         // TODO Auto-generated method stub
-        
+        System.out.println("sort removed");
       }
 
       @Override
       public void sortChanged(TableView tableView) {
         System.out.println("sort changed");
-        tableData.setComparator(new TableComparator(tableView));
+        //tableData.setComparator(new TableComparator(tableView));
         
       }});
     

Modified: lucene/sandbox/luke/src/org/apache/lucene/luke/ui/SearchTab.bxml
URL: http://svn.apache.org/viewvc/lucene/sandbox/luke/src/org/apache/lucene/luke/ui/SearchTab.bxml?rev=1002456&r1=1002455&r2=1002456&view=diff
==============================================================================
--- lucene/sandbox/luke/src/org/apache/lucene/luke/ui/SearchTab.bxml (original)
+++ lucene/sandbox/luke/src/org/apache/lucene/luke/ui/SearchTab.bxml Wed Sep 29 03:33:59 2010
@@ -7,7 +7,8 @@
 		<Border styles="{padding:6,backgroundColor:11,thickness:0}">
 			<content>
 				<ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
-					<TablePane styles="{horizontalSpacing:5,verticalSpacing:5,backgroundColor:11}">
+					<TablePane
+						styles="{horizontalSpacing:5,verticalSpacing:5,backgroundColor:11}">
 						<columns>
 							<TablePane.Column width="1*" />
 							<TablePane.Column width="1*" />
@@ -45,35 +46,31 @@
 										<PushButton width="95" buttonData="%searchTab_explainStructure"
 											action="explainStructure" />
 									</BoxPane>
-									<TabPane styles="{tabOrientation:'vertical'}">
+									<TabPane width="300" preferredWidth="300"
+										styles="{tabOrientation:'vertical'}">
 										<tabs>
-											<BoxPane
-												styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
+											<ScrollPane>
 												<TabPane.tabData>
 													<content:ButtonData text="%searchTab_Parsed" />
 												</TabPane.tabData>
-												<Border>
-													<content>
-														<Label text=""
-															styles="{horizontalAlignment:'center', verticalAlignment:'center'}" />
-													</content>
-												</Border>
-											</BoxPane>
+												<view>
+													<BoxPane>
 
-											<BoxPane
-												styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
+														<Label bxml:id="parsedQueryLabel" text="" />
+													</BoxPane>
+												</view>
+											</ScrollPane>
+											<ScrollPane>
 												<TabPane.tabData>
 													<content:ButtonData text="%searchTab_Rewritten" />
 												</TabPane.tabData>
-												<Border>
-													<content>
-														<Label text="320x240" preferredWidth="100"
-															preferredHeight="100"
-															styles="{horizontalAlignment:'center', verticalAlignment:'center'}" />
-													</content>
-												</Border>
-											</BoxPane>
+												<view>
+													<BoxPane styles="{fill:true}">
+														<Label bxml:id="rewrittenQueryLabel" text=""/>
 
+													</BoxPane>
+												</view>
+											</ScrollPane>
 										</tabs>
 
 									</TabPane>

Modified: lucene/sandbox/luke/src/org/apache/lucene/luke/ui/SearchTab.java
URL: http://svn.apache.org/viewvc/lucene/sandbox/luke/src/org/apache/lucene/luke/ui/SearchTab.java?rev=1002456&r1=1002455&r2=1002456&view=diff
==============================================================================
--- lucene/sandbox/luke/src/org/apache/lucene/luke/ui/SearchTab.java (original)
+++ lucene/sandbox/luke/src/org/apache/lucene/luke/ui/SearchTab.java Wed Sep 29 03:33:59 2010
@@ -32,7 +32,6 @@ import org.apache.lucene.analysis.core.W
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.luke.core.AccessibleHitCollector;
 import org.apache.lucene.luke.core.AccessibleTopHitCollector;
 import org.apache.lucene.luke.core.ClassFinder;
@@ -61,6 +60,7 @@ import org.apache.pivot.util.concurrent.
 import org.apache.pivot.wtk.Action;
 import org.apache.pivot.wtk.Alert;
 import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.Label;
 import org.apache.pivot.wtk.ListButton;
 import org.apache.pivot.wtk.MessageType;
 import org.apache.pivot.wtk.SplitPane;
@@ -85,6 +85,10 @@ public class SearchTab extends SplitPane
   private TableView searchResultsTable;
   @BXML
   private ListButton analyzerList;
+  @BXML
+  private Label parsedQueryLabel;
+  @BXML
+  private Label rewrittenQueryLabel;
 
   private DecimalFormat df = new DecimalFormat("0.0000");
 
@@ -133,73 +137,27 @@ public class SearchTab extends SplitPane
     populateAnalyzers();
   }
   
-  
-  public void showAllTermDoc(Object fText) {
-    final IndexReader ir = lukeMediator.getIndexInfo().getReader();
-    if (ir == null) {
-      // TODO:
-      //showStatus("MSG_NOINDEX");
+  /**
+   * Update the parsed and rewritten query views.
+   *
+   */
+  public void showParsed(String query) {
+    //Object qField = find("qField");
+
+    if (query.trim().equals("")) {
+      parsedQueryLabel.setText("<empty query>");
       return;
     }
-    //Object tabpane = find("maintpane");
-    //setInteger(tabpane, "selected", 2);
-    //Object qField = find("qField");
-    //setString(qField, "text", t.field() + ":" + t.text());
-    //Object qFieldParsed = find("qFieldParsed");
-    //Object ckScoreRes = find("ckScoreRes");
-    //Object ckOrderRes = find("ckOrderRes");
-    //Object cntRepeat = find("cntRepeat");
-    //final boolean scoreRes = getBoolean(ckScoreRes, "selected");
-    //final boolean orderRes = getBoolean(ckOrderRes, "selected");
-    //final int repeat = Integer.parseInt(getString(cntRepeat, "text"));
-    //final Query q = new TermQuery(t);
-    //setString(qFieldParsed, "text", q.toString());
-    Task<Object> showAllTermDocTask = new Task<Object>() {
-      
-      @Override
-      public Object execute() throws TaskExecutionException {
-        IndexSearcher is = null;
-        try {
-          is = new IndexSearcher(ir);
-          //Object sTable = find("sTable");
-          //removeAll(sTable);
-          //AllHitsCollector ahc = new AllHitsCollector(orderRes, scoreRes);
-         // _search(q, is, ahc, sTable, repeat);
-        } catch (Exception e) {
-          e.printStackTrace();
-          // TODO:
-          //errorMsg(e.getMessage());
-        } finally {
-          if (is != null) try {
-            is.close();
-          } catch (Exception e1) {}
-        }     
-        return null;
-      }
-    };
-    if (lukeMediator.isSlowAccess()) {
-      
-      TaskListener<Object> taskListener = new TaskListener<Object>() {
-        @Override
-        public void taskExecuted(Task<Object> task) {
-          // ai.setActive(false);
-          // lukeWindow.setEnabled(true);
-        }
-        
-        @Override
-        public void executeFailed(Task<Object> task) {
-          // ai.setActive(false);
-          // lukeWindow.setEnabled(true);
-        }
-      };
-      
-      showAllTermDocTask.execute(new TaskAdapter<Object>(taskListener));
-    } else {
-      try {
-        showAllTermDocTask.execute();
-      } catch (TaskExecutionException e) {
-        throw new RuntimeException(e);
-      }
+    try {
+      Query q = createQuery(query);
+      parsedQueryLabel.setText(q.toString());
+      //putProperty(qField, "qParsed", q);
+      q = q.rewrite(lukeMediator.getIndexInfo().getReader());
+      rewrittenQueryLabel.setText(q.toString());
+      //putProperty(qField, "qRewritten", q);
+    } catch (Throwable t) {
+      parsedQueryLabel.setText(t.getMessage());
+      //setString(qFieldRewritten, "text", t.getMessage());
     }
   }
   
@@ -209,8 +167,8 @@ public class SearchTab extends SplitPane
       //showStatus(MSG_NOINDEX);
       return;
     }
-    String queryS = queryTextArea.getText();
-    if (queryS.trim().equals("")) {
+    String query = queryTextArea.getText();
+    if (query.trim().equals("")) {
     //TODO: 
       //showStatus("FAILED: Empty query.");
       return;
@@ -232,9 +190,9 @@ public class SearchTab extends SplitPane
     //removeAll(sTable);
     Query q = null;
     try {
-      q = createQuery(queryS);
+      q = createQuery(query);
       indexInfo.getIndexSearcher().setSimilarity(sim);
-      //showParsed();
+      showParsed(query);
       search(q, indexInfo.getIndexSearcher(), col, repeat);
     } catch (Throwable e) {
       e.printStackTrace();



Mime
View raw message