changeset 17:64d6ac1a1354

parameter for search changed
author dwinter
date Fri, 16 Nov 2012 15:26:05 +0100
parents 70110fb915a9
children 1eb5e3f6444b
files restService/restService.py searchService/searchLines.py
diffstat 2 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/restService/restService.py	Fri Nov 16 12:30:30 2012 +0100
+++ b/restService/restService.py	Fri Nov 16 15:26:05 2012 +0100
@@ -16,7 +16,8 @@
     '/search','searcher',
     '/indexMeta/(.+)','indexMeta',
     '/','serviceDescription',
-    '/searchLines','searchLines'
+    '/searchLines','searchLines',
+    '/searchLines/annotator/search','searchLines'
 )
 
 app = web.application(urls, globals())
--- a/searchService/searchLines.py	Fri Nov 16 12:30:30 2012 +0100
+++ b/searchService/searchLines.py	Fri Nov 16 15:26:05 2012 +0100
@@ -8,6 +8,7 @@
 import web
 import urllib
 import os.path
+import json
 
 SOLR_SERVER="http://localhost:8983/solr"
 DRI_SERVER="http://localhost:8080/purl/"
@@ -31,7 +32,7 @@
         if not queryString:
             queryString="q=" 
         
-        docPath = paras.get("doc")
+        docPath = paras.get("uri")
         if docPath:
             #make sure that docpath="/mpiwg/online/..."
             if not docPath.startswith("/mpiwg/"):
@@ -48,7 +49,7 @@
                 docPath=docPath[0:-1]
                 
             docPath=os.path.normpath(docPath)
-            queryString+=""" archive-path-folder:"%s" """%docPath
+            queryString+=""" AND archive-path-folder:"%s" """%docPath
             
             
         
@@ -77,7 +78,7 @@
             
             
             
-            queryString+=' archive-path-indexMeta:"%s"'%indexMeta
+            queryString+=' AND archive-path-indexMeta:"%s"'%indexMeta
             
             
             
@@ -93,7 +94,7 @@
             if len(splitted)>1:
                 name=".".join(splitted[0,-1]) 
             
-            queryString+=" pf:%s"%name
+            queryString+=" AND pf:%s"%name
              
         
         
@@ -109,15 +110,26 @@
             rows.append(self.generateRowForJson(hitId, hit, queryString, pageSize))
             
             hitId+=1
-            print hit
+         
         
         
         
         
         
+        returnJSON={}
         
-        return rows
-    
+        returnJSON['rows']=rows
+        returnJSON['total']=len(rows)
+        
+        web.header('Content-Type', 'application/json')
+        web.header('Access-Control-Allow-Origin', '*')
+        web.header('Access-Control-Allow-Credentials', 'true')
+        
+        
+        return json.dumps(returnJSON)
+
+
+        
     def generateRowForJson(self,hitID,hit,query,pageSize):
         
         ret={}
@@ -147,8 +159,8 @@
     def generateAreaForJson(self,x,y):
         
         area={}
-        area["height"]=str(y[0]-x[0])
-        area["width"]=str(y[1]-x[1])
+        area["width"]=str(y[0]-x[0])
+        area["height"]=str(y[1]-x[1])
         area["y"]=str(x[1])
         area["x"]=str(x[0])
         
@@ -162,8 +174,7 @@
         return xneu,yneu
         
     def getPageSize(self,queryString):
-        print queryString
-        
+      
         response = self.searchText(queryString,wt="json")
         
         for hit in response: #sollte eigentlich nur einen geben