changeset 53:56accc959f8c

remove SORT_BY_VALUE
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 06 Jul 2021 20:19:14 -0600
parents 7df8ec497281
children 6bd33547304f
files src/global/Site.java src/global/web/Index.java src/global/web/Index.jtp src/global/web/RootForums.java src/global/web/RootForums.jtp
diffstat 5 files changed, 6 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
diff -r 7df8ec497281 -r 56accc959f8c src/global/Site.java
--- a/src/global/Site.java	Fri Jul 02 00:36:59 2021 -0600
+++ b/src/global/Site.java	Tue Jul 06 20:19:14 2021 -0600
@@ -61,14 +61,9 @@
 	public static final String FILE_COUNT_FLD = "file_count";
 	public static final String FILE_NODE_RATIO_FLD = "file_node_ratio";
 	public static final String MONTHLY_VIEWS_FLD = "monthly_views";
-	public static final String VALUE_FLD = "value";
 
 	public static final Sort SORT_BY_ACTIVITY = new Sort(new SortField(ACTIVITY_FLD, SortField.INT, true));
 	public static final Sort SORT_BY_FILE_NODE_RATIO = new Sort(new SortField(FILE_NODE_RATIO_FLD, SortField.INT, true));
-	public static final Sort SORT_BY_VALUE = new Sort(
-		new SortField(VALUE_FLD, SortField.INT, true),
-		new SortField(NODE_COUNT_FLD, SortField.INT, true)
-	);
 
 	public static final Analyzer analyzer = new SnowballAnalyzer(Version.LUCENE_CURRENT,"English");
 	private static final FSDirectory dir1;
@@ -89,13 +84,7 @@
 	public static FSDirectory dir() {
 		return dir2;
 	}
-/*
-	static synchronized void clear()
-		throws IOException
-	{
-		new IndexWriter(dir,analyzer,true,IndexWriter.MaxFieldLength.LIMITED).close();
-	}
-*/
+
 	public static boolean isReindexing() {
 		return thread != null && thread.isAlive();
 	}
@@ -143,16 +132,7 @@
 			indexWriter.close();
 		}
 	}
-/*
-	public static synchronized void removeBySubject(String subject)
-		throws IOException
-	{
-		Term term = new Term( SUBJECT_FLD, subject );
-		IndexWriter indexWriter = new IndexWriter(dir2,analyzer,IndexWriter.MaxFieldLength.LIMITED);
-		indexWriter.deleteDocuments(term);
-		indexWriter.close();
-	}
-*/
+
 	private static synchronized void reindex1(Server server,IndexWriter indexWriter)
 		throws SQLException, IOException
 	{
@@ -256,49 +236,9 @@
 		}
 	}
 
-	private static final Pattern ptn = Pattern.compile("([^,]+),(\\d+|\"[0-9,]+\")");
-
-	private static Map<String,Integer> domainMap()
-		throws IOException
-	{
-		Map<String,Integer> map = new HashMap<String,Integer>();
-		File siteFile = new File("data/sites.csv");
-		if( !siteFile.exists() )
-			return map;
-		BufferedReader in = new BufferedReader(new FileReader(siteFile));
-		String line = in.readLine();
-		try {
-			while (!ptn.matcher(line).matches())
-				line = in.readLine();
-			while (true) {
-				if (line == null)
-					break;
-				if (line.length() > 0) {
-					if( line.startsWith(",") )
-						break;
-					Matcher m = ptn.matcher(line);
-					if (!m.matches())
-						throw new RuntimeException(line);
-					String domain = m.group(1);
-					String amt = m.group(2);
-					amt = amt.replaceAll("[,\"]", "");
-					int sessions = Integer.parseInt(amt);
-					map.put(domain, sessions);
-				}
-				line = in.readLine();
-			}
-			in.close();
-		} catch (RuntimeException e) {
-			logger.error("Error in line: " + line, e);
-			throw e;
-		}
-		return map;
-	}
-
 	private static void reindex2()
 		throws IOException
 	{
-		Map<String,Integer> domainMap = domainMap();
 		IndexReader reader = IndexReader.open(dir1);
 		IndexWriter indexWriter = new IndexWriter(dir2,analyzer,true,IndexWriter.MaxFieldLength.LIMITED);
 		try {
@@ -342,10 +282,6 @@
 				}
 				int monthlyViews = ((NumericField)data.getFieldable(MONTHLY_VIEWS_FLD)).getNumericValue().intValue();
 				doc.add( new NumericField(MONTHLY_VIEWS_FLD,Field.Store.YES,true).setIntValue(monthlyViews) );
-				Integer sessions = domainMap.get(domain);
-				if( sessions == null )
-					sessions = 0;
-				doc.add( new NumericField(VALUE_FLD,Field.Store.YES,true).setIntValue(sessions) );
 				indexWriter.addDocument(doc);
 			}
 		} finally {
@@ -442,9 +378,4 @@
 		return fld.getNumericValue().intValue();
 	}
 
-	public int value() {
-		NumericField fld = (NumericField)doc.getFieldable(VALUE_FLD);
-		return fld.getNumericValue().intValue();
-	}
-
 }
diff -r 7df8ec497281 -r 56accc959f8c src/global/web/Index.java
--- a/src/global/web/Index.java	Fri Jul 02 00:36:59 2021 -0600
+++ b/src/global/web/Index.java	Tue Jul 06 20:19:14 2021 -0600
@@ -77,7 +77,7 @@
 		TopDocs hits;
 		try {
 			searcher = new IndexSearcher(Site.dir());
-			hits = searcher.search( query, 60, Site.SORT_BY_VALUE );
+			hits = searcher.search( query, 60, Site.SORT_BY_ACTIVITY );
 		} catch(IOException e) {
 			logger.error("Index error", e);
 			
diff -r 7df8ec497281 -r 56accc959f8c src/global/web/Index.jtp
--- a/src/global/web/Index.jtp	Fri Jul 02 00:36:59 2021 -0600
+++ b/src/global/web/Index.jtp	Tue Jul 06 20:19:14 2021 -0600
@@ -154,7 +154,7 @@
 		TopDocs hits;
 		try {
 			searcher = new IndexSearcher(Site.dir());
-			hits = searcher.search( query, 60, Site.SORT_BY_VALUE );
+			hits = searcher.search( query, 60, Site.SORT_BY_ACTIVITY );
 		} catch(IOException e) {
 			logger.error("Index error", e);
 			%>[Rebuilding Index]<%
diff -r 7df8ec497281 -r 56accc959f8c src/global/web/RootForums.java
--- a/src/global/web/RootForums.java	Fri Jul 02 00:36:59 2021 -0600
+++ b/src/global/web/RootForums.java	Tue Jul 06 20:19:14 2021 -0600
@@ -51,7 +51,7 @@
 		TopDocs hits;
 		try {
 			searcher = new IndexSearcher(Site.dir());
-			hits = searcher.search( Index.query, iRec+ROWS_PER_PAGE, Site.SORT_BY_VALUE );
+			hits = searcher.search( Index.query, iRec+ROWS_PER_PAGE, Site.SORT_BY_ACTIVITY );
 		} catch(IOException e) {
 			throw new RuntimeException(e);
 		}
diff -r 7df8ec497281 -r 56accc959f8c src/global/web/RootForums.jtp
--- a/src/global/web/RootForums.jtp	Fri Jul 02 00:36:59 2021 -0600
+++ b/src/global/web/RootForums.jtp	Tue Jul 06 20:19:14 2021 -0600
@@ -51,7 +51,7 @@
 		TopDocs hits;
 		try {
 			searcher = new IndexSearcher(Site.dir());
-			hits = searcher.search( Index.query, iRec+ROWS_PER_PAGE, Site.SORT_BY_VALUE );
+			hits = searcher.search( Index.query, iRec+ROWS_PER_PAGE, Site.SORT_BY_ACTIVITY );
 		} catch(IOException e) {
 			throw new RuntimeException(e);
 		}