1. jummp
  2. jummp

Commits

Raza Ali  committed 62838f8

Index more fields, hopefully reduce DB access later on

  • Participants
  • Parent commits 640f796
  • Branches master

Comments (0)

Files changed (3)

File grails-app/services/net/biomodels/jummp/core/ModelService.groovy

View file
  • Ignore whitespace
     static transactional = true
 
     
+    /**
+    * Returns search results for query restricted Models the user has access to.
+    *
+    * Executes the @p query, restricting results to Models the current user has access to, 
+    * @param query freetext search on models
+    * @return List of Models
+    **/
+    @PostLogging(LoggingEventType.RETRIEVAL)
+    @Profiled(tag="modelService.getAllModels")
     public Set<ModelTransportCommand> searchModels(String query) {
     	    def searchEngine=grailsApplication.mainContext.getBean("searchEngine")
-    	    /*Set<Document> results=searchEngine.performSearch("name", query)
-    	    results.addAll(searchEngine.performSearch("description", query))
-    	    results.addAll(searchEngine.performSearch("content", query))*/
     	    Set<Document> results=searchEngine.performSearch(["name","description","content"] as String[], query)
     	    
     	    Set<ModelTransportCommand> returnVals=new HashSet<ModelTransportCommand>()

File src/groovy/net/biomodels/jummp/search/SearchProvider.groovy

View file
  • Ignore whitespace
 		}
 		IndexSearcher indexSearcher = mgr.acquire();
 		try {
-			TopDocs topDocs = indexSearcher.search(q,10);
+			TopDocs topDocs = indexSearcher.search(q,1000);
 			for (int i=0; i<topDocs.totalHits; i++) {
 				docs.add(indexSearcher.doc(topDocs.scoreDocs[i].doc))
 			}

File src/groovy/net/biomodels/jummp/search/UpdatedRepositoryListener.groovy

View file
  • Ignore whitespace
 		String name = revision.name
 		String description = revision.description
 		String content=modelDelegateService.getSearchIndexingContent(revision)
-
+		Document doc = new Document();
+		
+		/*
+		*	Indexed fields
+		*/
 		Field nameField =
-			new Field("name",name,Field.Store.YES,Field.Index.NOT_ANALYZED);
+			new Field("name",name,Field.Store.YES,Field.Index.ANALYZED);
 		Field descriptionField = 
 			new Field("description",description,Field.Store.NO,Field.Index.ANALYZED); 
+		Field formatField = 
+			new Field("format",""+revision.format.name,Field.Store.YES,Field.Index.NOT_ANALYZED);
 		Field contentField = 
 			new Field("content",content,Field.Store.NO,Field.Index.ANALYZED); 
+		
+		doc.add(nameField);
+		doc.add(descriptionField);
+		doc.add(formatField)
+		doc.add(contentField)
+			
+			
+		/*
+		*	Stored fields. Hopefully will be used to display the search results one day
+		*	instead of going to the database for each model. When we find a solution to needing to
+		*	look in the database to figure out if the user has access to a model. 
+		*/
 		Field idField = 
 			new Field("model_id",""+revision.model.id,Field.Store.YES,Field.Index.NO); 
 		Field versionField = 
 			new Field("versionNumber",""+revision.revisionNumber,Field.Store.YES,Field.Index.NO);
-		
-
-		Document doc = new Document();
-		// Add these fields to a Lucene Document
+		Field submittedField = 
+			new Field("submissionDate",""+revision.model.submissionDate,Field.Store.YES,Field.Index.NO);
+		Field submitterField = 
+			new Field("submitter",""+revision.model.submitter,Field.Store.YES,Field.Index.NOT_ANALYZED);
 		doc.add(idField);
 		doc.add(versionField);
-		doc.add(nameField);
-		doc.add(descriptionField);
-		doc.add(contentField)
-
-		//Step 3: Add this document to Lucene Index.
+		doc.add(submittedField)
+		doc.add(submitterField)
+		
 		indexWriter.addDocument(doc);
 		indexWriter.commit();
 	}