cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/3] git commit: CXF-5923: Create sample to demonstrate usage of search extension with Lucene and Tika. Added OR/AND search criteria support.
Date Tue, 14 Oct 2014 14:46:25 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 0cfedc9a8 -> 92502a5e2


CXF-5923: Create sample to demonstrate usage of search extension with Lucene and Tika. Added
OR/AND search criteria support.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4fe78449
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4fe78449
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4fe78449

Branch: refs/heads/master
Commit: 4fe7844935f9b4ad797760613d143949f9448905
Parents: 42934a1
Author: reta <drreta@gmail.com>
Authored: Tue Oct 14 10:39:01 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Tue Oct 14 10:39:01 2014 -0400

----------------------------------------------------------------------
 .../src/main/resources/browser/index.html       | 43 ++++++++++++++++++--
 1 file changed, 39 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4fe78449/distribution/src/main/release/samples/jax_rs/search/src/main/resources/browser/index.html
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/search/src/main/resources/browser/index.html
b/distribution/src/main/release/samples/jax_rs/search/src/main/resources/browser/index.html
index dc1c2d7..2505e83 100644
--- a/distribution/src/main/release/samples/jax_rs/search/src/main/resources/browser/index.html
+++ b/distribution/src/main/release/samples/jax_rs/search/src/main/resources/browser/index.html
@@ -33,6 +33,15 @@
 			    	<button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
 			    </div>
 		    </div>
+
+			<div class="btn-group" data-toggle="buttons">
+				<label class="btn btn-primary active"> 
+					<input type="radio" name="options" id="any" />Any keyword (OR)
+				</label> 
+				<label class="btn btn-primary"> 
+					<input type="radio" name="options" id="all" />All keywords (AND)
+				</label> 
+			</div>
 		</form>
 		
 		<div class="fluent-container" id="results">
@@ -40,6 +49,8 @@
     </div> <!-- /container -->
     
     <script type="text/javascript">
+        $( "#any" ).prop( "checked", true );
+    
         function handleError(request, status, error, form) {
 			$( "#error-message" ).removeClass('hide');
 			
@@ -81,14 +92,38 @@
 	    });
     	
     	$( "#form-search" ).submit(function(e) {    		
-    		var query = $( "#search-query" ).val();
+    		var query = $( "#search-query" ).val().trim();
     		$( "#error-message" ).addClass('hide');
     		$( "#results" ).html("");
     		
     		if( query !== "" ) {
-    			var encodedQuery = encodeURIComponent( query );
-    			var encodedWildcardsQuery = encodeURIComponent( "*" + query + "*" );
-    			var filter = "ct==" + encodedQuery + ",source==" + encodedWildcardsQuery; 
+    			var contentQuery = "";
+    			var wildcardsQuery = "";
+    			
+    			if( $( "#all" ).is( ":checked" ) ) {
+    				contentQuery += "(";
+    				wildcardsQuery += ",(";
+
+    				query.split( " " ).forEach( function( entry ) {
+    					if( contentQuery.length > 1 ) contentQuery += ";";
+    					if( wildcardsQuery.length > 2 ) wildcardsQuery += ";";
+    					
+    					contentQuery += "ct==" + encodeURIComponent( entry );
+    					wildcardsQuery += "source==" + encodeURIComponent( "*" + entry + "*" );
+        			} );
+
+    				contentQuery += ")";
+    				wildcardsQuery += ")";
+    			} else {
+    				contentQuery = "ct==" + encodeURIComponent( query );
+    			    			
+    				query.split( " " ).forEach( function( entry ) {    				
+    					wildcardsQuery += ",source==" + encodeURIComponent( "*" + entry + "*" );
+    			    } );
+    			}
+    			
+    			var encodedWildcardsQuery = encodeURIComponent( wildcardsQuery.trim() );
+    			var filter = contentQuery + wildcardsQuery;
 
 	    		$.ajax({
 	    			url: $(this).attr("action") + "?$filter=" + filter,


Mime
View raw message