Skip to content

Commit

Permalink
Getting away from me, but here is a searchapi end point...
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Sep 15, 2023
1 parent ccd42e5 commit 93df2d7
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 32 deletions.
Binary file added app/assets/images/searchapi-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/assets/javascripts/controllers/wizardModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ angular.module('QuepidApp')
settingsForValidation = angular.copy($scope.pendingWizardSettings);
settingsForValidation.searchEngine = 'solr';
}
else if ($scope.pendingWizardSettings.searchEngine === 'searchapi'){
// we map to our response parser to use.
settingsForValidation = angular.copy($scope.pendingWizardSettings);
settingsForValidation.searchEngine = $scope.pendingWizardSettings.responseParser;
}

var validator = new SettingsValidatorFactory(settingsForValidation);

Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/services/caseCSVSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,14 +470,14 @@
function fixObjectKeys (docs){
var newDocs = [];
angular.forEach(docs, function (doc) {
var newDoc = {}
var newDoc = {};
Object.keys(doc).forEach(key => {
const trimmedKey = key.trim();
newDoc[trimmedKey] = doc[key];
});
newDocs.push(newDoc);
});
return newDocs
return newDocs;
}
}
]);
Expand Down
5 changes: 4 additions & 1 deletion app/assets/javascripts/services/queriesSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ angular.module('QuepidApp')
// we need a better way of handling this. Basically we are saying a static search engine is
// treated like Solr. But if we have more generic search apis, they will need a
// custom parser...
passedInSettings.searchEngine = 'solr';
passedInSettings.searchEngine = 'solr';
}
else if (passedInSettings.searchEngine === 'searchapi'){
passedInSettings.searchEngine = 'es';
}

if (passedInSettings.searchEngine === 'solr') {
Expand Down
55 changes: 36 additions & 19 deletions app/assets/javascripts/services/settingsSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ angular.module('QuepidApp')
numberOfRows: 10,
searchEngine: 'static'
// no searchUrl or urlFormat because it's code generated!
},
searchapi: {
queryParams: '{ }',
escapeQuery: true,
apiMethod: 'POST',
headerType: 'None',
customHeaders: '',
fieldSpec: 'id:_id',
idField: 'id',
titleField: 'title',
additionalFields: [],
numberOfRows: 10,
searchEngine: 'searchapi',
urlFormat: 'http(s?)://yourdomain.com:9200/<path>/<etc>',
// no searchUrl or urlFormat because it's code generated!
}
};

Expand Down Expand Up @@ -243,29 +258,31 @@ angular.module('QuepidApp')

this.demoSettingsChosen = function(searchEngine, newUrl){
var useTMDBDemoSettings = false;
if (searchEngine === 'solr'){
if (newUrl === null || angular.isUndefined(newUrl)){
useTMDBDemoSettings = true;
}
else if (newUrl === this.tmdbSettings['solr'].insecureSearchUrl || newUrl === this.tmdbSettings['solr'].secureSearchUrl ){
useTMDBDemoSettings = true;
}
else {
useTMDBDemoSettings = false;
}
if (angular.isUndefined(this.tmdbSettings[searchEngine])){
useTMDBDemoSettings = false; // yes this isn't actually needed.
}
// Could be refactored
else if (searchEngine === 'vectara' || searchEngine === 'static') {
useTMDBDemoSettings = false;
}
else {
if (newUrl === this.tmdbSettings[searchEngine].searchUrl) {
useTMDBDemoSettings = true;
else {
if (searchEngine === 'solr'){
if (newUrl === null || angular.isUndefined(newUrl)){
useTMDBDemoSettings = true;
}
// We actually have seperate demos for Solr based on http and https urls.
else if (newUrl === this.tmdbSettings['solr'].insecureSearchUrl || newUrl === this.tmdbSettings['solr'].secureSearchUrl ){
useTMDBDemoSettings = true;
}
else {
useTMDBDemoSettings = false;
}
}
else {
useTMDBDemoSettings = false;
if (newUrl === this.tmdbSettings[searchEngine].searchUrl) {
useTMDBDemoSettings = true;
}
else {
useTMDBDemoSettings = false;
}
}
}
}
return useTMDBDemoSettings;
};

Expand Down
59 changes: 49 additions & 10 deletions app/assets/templates/views/wizardModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h2>What Search Endpoint do you want to connect to?</h2>
<div>
<uib-accordion>
<div uib-accordion-group class="panel-default" heading="Use an existing Search Endpoint" >
<div class="alert alert-warning" role="alert" ng-if="!haveSearchEndpoints">
<div class="alert alert-warning" role="alert" ng-if="listSearchEndpoints().length === 0">
You do not have any Search Endpoints created yet.
</div>
<select
Expand All @@ -42,7 +42,7 @@ <h2>What Search Endpoint do you want to connect to?</h2>

<button class="btn btn-primary pull-right continue" ng-click="pickSearchEndpoint()" ng-disabled="pendingWizardSettings.searchEndpointId == null">Continue</button>

<button class="btn btn-danger" ng-click="skipValidation()" ng-disabled="validating">
<button class="btn btn-danger" ng-click="skipValidation()" ng-disabled="validating" ng-show="pendingWizardSettings.searchEndpointId">
<span ng-hide="validating">Skip Validation</span>
</button>
</div>
Expand All @@ -60,14 +60,20 @@ <h2>What Search Endpoint do you want to connect to?</h2>
<input type="radio" value="os" ng-model="pendingWizardSettings.searchEngine" ng-change="changeSearchEngine()">
<img ng-src="images/os.png" alt='OpenSearch' width="150px" />
</label>
<label>
</div>
<div style="text-align: center;">
<label style="margin-right: 25px;">
<input type="radio" value="vectara" ng-model="pendingWizardSettings.searchEngine" ng-change="changeSearchEngine()">
<img ng-src="images/vectara.png" alt='Vectara' width="150px" />
</label>
<label>
<label style="margin-right: 25px;">
<input type="radio" value="static" ng-model="pendingWizardSettings.searchEngine" ng-change="changeSearchEngine()">
<img ng-src="images/static.png" alt='Static' width="150px" height="50px" />
</label>
<label>
<input type="radio" value="searchapi" ng-model="pendingWizardSettings.searchEngine" ng-change="changeSearchEngine()">
<img ng-src="images/searchapi.png" alt='Search API' width="50px" height="50px" />
</label>
</div>

<br>
Expand Down Expand Up @@ -152,7 +158,7 @@ <h2>What Search Endpoint do you want to connect to?</h2>
<span ng-if="pendingWizardSettings.searchEngine === 'static'">
<!-- Copied from import-ratings component -->
<p>
A "Static" search endpoint is a great way to gather human judgements and leverage Quepid's existing evaluation tools without having a live connection to a search engine.
A "Static" (or "Offline") search endpoint is a great way to gather human judgements and leverage Quepid's existing evaluation tools without requiring a live connection to a search engine.
</p>
<p>
<button type="button" class="btn btn-sm btn-default" ng-click="isStaticCollapsed = !isStaticCollapsed">Static Dataset</button>
Expand All @@ -169,10 +175,10 @@ <h2>What Search Endpoint do you want to connect to?</h2>
The CSV file should have the headers: <code>Query Text,Doc ID,Doc Position</code>.
Then, all the document fields you want displayed follow as columns with the header being the name of the field.
<pre>
Query Text,Doc ID,Doc Position, Movie Title
star wars,527641,1, Star Wars
star wars,9426,2, Star Wars: The Empire Strikes Back
star wars,1921,3, Star Wars: Return of the Jedi
Query Text,Doc ID,Doc Position, Movie Title
star wars,527641,1, Star Wars
star wars,9426,2, Star Wars: The Empire Strikes Back
star wars,1921,3, Star Wars: Return of the Jedi
</pre>
Please note that the additional columns that a Snapshot export has are ignored.
</span>
Expand Down Expand Up @@ -222,7 +228,40 @@ <h2>CSV</h2>
</div>
</div>
</div>
</span>
</span>

<span ng-if="pendingWizardSettings.searchEngine === 'searchapi'">
<p>
<button type="button" class="btn btn-sm btn-default" ng-click="isSearchAPICollapsed = !isSearchAPICollapsed">Search API Configuration</button>
</p>
<div uib-collapse="!isSearchAPICollapsed">
<div class="well well-sm">
<div class="form-group clearfix">
<label class="col-sm-3 control-label">API Method</label>
<div class="col-sm-9">
<select class="form-control" ng-model="pendingWizardSettings.apiMethod" ng-change="resetUrlValid()">
<option>POST</option>
<option>GET</option>
<option>JSONP</option>
</select>
<p class="help-block">POST and GET are the most common.</p>
</div>
</div>
<div class="form-group clearfix">
<label class="col-sm-3 control-label">Response Parser</label>
<div class="col-sm-9">
<select class="form-control" ng-model="pendingWizardSettings.responseParser" ng-change="resetUrlValid()">
<option>solr</option>
<option>es</option>
<option>os</option>
<option>vectara</option>
</select>
<p class="help-block">We need to know how to parse the response from your search engine using a Splainer supported parser.</p>
</div>
</div>
</div>
</div>
</span>

<span ng-if="pendingWizardSettings.searchEngine !== 'solr' && pendingWizardSettings.searchEngine !== 'static'">
<p>
Expand Down
Binary file added public/images/searchapi-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/searchapi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 93df2d7

Please sign in to comment.