Skip to content

Commit

Permalink
#4 Passing tests for simple search and refreshing of an index
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWatson committed Aug 31, 2012
1 parent f362d56 commit 07143ee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cfelasticsearch/api/Wrapper.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,33 @@
</cfscript>
</cffunction>

<cffunction name="search" access="public" returntype="struct" output="false">
<cfargument name="index" type="string" required="true" />
<cfargument name="q" type="string" required="true" />

<cfscript>
var uri = "/#_safeIndexName( index )#/_search?q=#q#";

return _call(
uri = uri
, method = "GET"
);
</cfscript>
</cffunction>

<cffunction name="refresh" access="public" returntype="struct" output="false">
<cfargument name="index" type="string" required="true" />

<cfscript>
var uri = "/#_safeIndexName( index )#/_refresh";

return _call(
uri = uri
, method = "POST"
);
</cfscript>
</cffunction>

<!--- private utility --->
<cffunction name="_call" access="private" returntype="any" output="false">
<cfargument name="uri" type="string" required="true" />
Expand Down
1 change: 1 addition & 0 deletions tests/integration/WrapperTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
var result = "";
var nDocs = _addABunchOfDocs( indexName, type );

wrapper.refresh( indexName );
result = wrapper.search( indexName, "*" );
super.assert( IsStruct( result ) and StructKeyExists( result, 'hits' ), "Result was not in expected format" );
super.assertEquals( nDocs, result.hits.total );
Expand Down

0 comments on commit 07143ee

Please sign in to comment.