diff options
author | Arnstein Ressem <aressem@oath.com> | 2018-08-09 10:27:43 +0200 |
---|---|---|
committer | Arnstein Ressem <aressem@oath.com> | 2018-08-09 10:27:43 +0200 |
commit | 6d61753ac389a884430be9e2eb9bbbd216ea4db5 (patch) | |
tree | 9a1b00c5ac40a0c0ea9d822658e225c90adab84b /container-search-gui/src | |
parent | b80a8292c21e0c0dd678024928077e3e268de789 (diff) | |
parent | e2887cb7299438c02bc49d888aaaf2e51631ace9 (diff) |
Merge branch 'master' into aressem/kill-mbuild
Diffstat (limited to 'container-search-gui/src')
9 files changed, 271 insertions, 1242 deletions
diff --git a/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java b/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java index 0f4eebd7fd7..45a616ce473 100644 --- a/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java +++ b/container-search-gui/src/main/java/com/yahoo/search/query/gui/GUIHandler.java @@ -2,22 +2,39 @@ package com.yahoo.search.query.gui; import com.google.inject.Inject; + +import com.yahoo.container.QrSearchersConfig; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; - - +import com.yahoo.prelude.IndexModel; +import com.yahoo.prelude.fastsearch.CacheControl; +import com.yahoo.prelude.querytransform.RecallSearcher; +import com.yahoo.search.Query; +import com.yahoo.search.query.Model; +import com.yahoo.search.query.Presentation; +import com.yahoo.search.query.Ranking; +import com.yahoo.search.query.ranking.Diversity; +import com.yahoo.search.query.ranking.MatchPhase; import com.yahoo.search.query.restapi.ErrorResponse; +import com.yahoo.search.yql.MinimalQueryInserter; +import com.yahoo.vespa.config.search.RankProfilesConfig; +import com.yahoo.search.config.IndexInfoConfig; import com.yahoo.yolean.Exceptions; -import java.io.File; +import org.json.JSONException; +import org.json.JSONObject; +import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; import java.util.logging.Level; + /** * Takes requests on /querybuilder * @@ -26,9 +43,15 @@ import java.util.logging.Level; public class GUIHandler extends LoggingRequestHandler { + private final IndexModel indexModel; + private final RankProfilesConfig rankProfilesConfig; + @Inject - public GUIHandler(Context parentCtx) { - super(parentCtx); + public GUIHandler(Context parentContext, IndexInfoConfig indexInfo, QrSearchersConfig clusters, RankProfilesConfig rankProfilesConfig) { + super(parentContext); + this.indexModel = new IndexModel(indexInfo, clusters); + this.rankProfilesConfig = rankProfilesConfig; + } @Override @@ -47,75 +70,141 @@ public class GUIHandler extends LoggingRequestHandler { } private HttpResponse handleGET(HttpRequest request) { - com.yahoo.restapi.Path path = new com.yahoo.restapi.Path(request.getUri().getPath()); + com.yahoo.restapi.Path path = new com.yahoo.restapi.Path(request.getUri().getPath()); if (path.matches("/querybuilder/")) { - return new FileResponse("_includes/index.html"); + return new FileResponse("_includes/index.html", null, null); } if (!path.matches("/querybuilder/{*}") ) { - return ErrorResponse.notFoundError("Nothing at " + path); + return ErrorResponse.notFoundError("Nothing at path:" + path); } String filepath = path.getRest(); - if (!isValidPath(GUIHandler.class.getClassLoader().getResource("gui").getFile()+"/"+filepath)){ - return ErrorResponse.notFoundError("Nothing at " + path); + if (!isValidPath(filepath) && !filepath.equals("config.json")){ + return ErrorResponse.notFoundError("Nothing at path:" + filepath); } - return new FileResponse(filepath); + return new FileResponse(filepath, indexModel, rankProfilesConfig); } private static boolean isValidPath(String path) { - File file = new File(path); - return file.exists(); + InputStream in = GUIHandler.class.getClassLoader().getResourceAsStream("gui/"+path); + boolean isValid = (in != null); + if(isValid){ + try { in.close(); } catch (IOException e) {/* Problem with closing inputstream */} + } + + return isValid; } private static class FileResponse extends HttpResponse { - private final Path path; + private final String path; + private final IndexModel indexModel; + private final RankProfilesConfig rankProfilesConfig; - public FileResponse(String relativePath) { + public FileResponse(String relativePath, IndexModel indexModel, RankProfilesConfig rankProfilesConfig) { super(200); - this.path = Paths.get(GUIHandler.class.getClassLoader().getResource("gui").getFile(), relativePath); + this.path = relativePath; + this.indexModel = indexModel; + this.rankProfilesConfig = rankProfilesConfig; + } @Override public void render(OutputStream out) throws IOException { - byte[] data = Files.readAllBytes(path); - out.write(data); + InputStream is; + if (this.path.equals("config.json")){ + String json = "{}"; + try { json = getGUIConfig(); } catch (JSONException e) { /*Something happened while parsing JSON */ } + is = new ByteArrayInputStream(json.getBytes()); + } else{ + is = GUIHandler.class.getClassLoader().getResourceAsStream("gui/"+this.path); + } + byte[] buf = new byte[1024]; + int numRead; + while ( (numRead = is.read(buf) ) >= 0) { + out.write(buf, 0, numRead); + } } @Override public String getContentType() { - if (path.toString().endsWith(".css")) { + if (path.endsWith(".css")) { return "text/css"; - } else if (path.toString().endsWith(".js")) { + } else if (path.endsWith(".js")) { return "application/javascript"; - } else if (path.toString().endsWith(".html")) { + } else if (path.endsWith(".html")) { return "text/html"; - }else if (path.toString().endsWith(".php")) { + } else if (path.endsWith(".php")) { return "text/php"; - }else if (path.toString().endsWith(".svg")) { + } else if (path.endsWith(".svg")) { return "image/svg+xml"; - }else if (path.toString().endsWith(".eot")) { + } else if (path.endsWith(".eot")) { return "application/vnd.ms-fontobject"; - }else if (path.toString().endsWith(".ttf")) { + } else if (path.endsWith(".ttf")) { return "font/ttf"; - }else if (path.toString().endsWith(".woff")) { + } else if (path.endsWith(".woff")) { return "font/woff"; - }else if (path.toString().endsWith(".woff2")) { + } else if (path.endsWith(".woff2")) { return "font/woff2"; - }else if (path.toString().endsWith(".otf")) { + } else if (path.endsWith(".otf")) { return "font/otf"; - }else if (path.toString().endsWith(".png")) { + } else if (path.endsWith(".png")) { return "image/png"; - }else if (path.toString().endsWith(".xml")) { + } else if (path.endsWith(".xml")) { return "application/xml"; - }else if (path.toString().endsWith(".ico")) { + } else if (path.endsWith(".ico")) { return "image/x-icon"; - }else if (path.toString().endsWith(".json")) { + } else if (path.endsWith(".json")) { return "application/json"; - }else if (path.toString().endsWith(".ttf")) { + } else if (path.endsWith(".ttf")) { return "font/ttf"; } return "text/html"; } - } -} + private String getGUIConfig() throws JSONException { + JSONObject json = new JSONObject(); + json.put("ranking_properties", Arrays.asList("propertyname")); + json.put("ranking_features", Arrays.asList("featurename")); + + List<String> sources = new ArrayList<>(); + + try { + sources = new ArrayList<>(indexModel.getMasterClusters().keySet()); + } catch (NullPointerException ex){ /* clusters are not set */ } + json.put("model_sources", sources); + + List<String> rankProfiles = new ArrayList<>(); + try { + rankProfilesConfig.rankprofile().forEach(rankProfile -> rankProfiles.add(rankProfile.name())); + } catch (NullPointerException ex){ /* rankprofiles are not set*/ } + json.put("ranking_profile", rankProfiles); + + + // Creating map from parent to children for GUI: parameter --> child-parameters + HashMap<String, List<String>> childMap = new HashMap<>(); + childMap.put(Model.MODEL, Arrays.asList(Model.DEFAULT_INDEX, Model.ENCODING, Model.LANGUAGE, Model.QUERY_STRING, Model.RESTRICT, Model.SEARCH_PATH, Model.SOURCES, Model.TYPE)); + childMap.put(Ranking.RANKING, Arrays.asList(Ranking.LOCATION, Ranking.FEATURES, Ranking.LIST_FEATURES, Ranking.PROFILE, Ranking.PROPERTIES, Ranking.SORTING, Ranking.FRESHNESS, Ranking.QUERYCACHE, Ranking.MATCH_PHASE)); + childMap.put(Ranking.RANKING +"."+ Ranking.MATCH_PHASE, Arrays.asList(MatchPhase.MAX_HITS, MatchPhase.ATTRIBUTE, MatchPhase.ASCENDING, Ranking.DIVERSITY)); + childMap.put(Ranking.RANKING +"."+ Ranking.MATCH_PHASE +"."+Ranking.DIVERSITY, Arrays.asList(Diversity.ATTRIBUTE, Diversity.MINGROUPS)); + childMap.put(Presentation.PRESENTATION, Arrays.asList(Presentation.BOLDING, Presentation.FORMAT, Presentation.SUMMARY, "template", Presentation.TIMING )); + childMap.put("trace", Arrays.asList("timestamps")); + childMap.put("tracelevel", Arrays.asList("rules")); + childMap.put("metrics", Arrays.asList("ignore")); + childMap.put("collapse", Arrays.asList("summary")); + childMap.put("pos", Arrays.asList("ll", "radius", "bb", "attribute")); + childMap.put("streaming", Arrays.asList("userid", "groupname", "selection", "priority", "maxbucketspervisitor")); + childMap.put("rules", Arrays.asList("off", "rulebase")); + json.put("childMap", childMap); + + List<String> levelZeroParameters = Arrays.asList(MinimalQueryInserter.YQL.toString(), Query.HITS.toString(), Query.OFFSET.toString(), + "queryProfile", Query.NO_CACHE.toString(), Query.GROUPING_SESSION_CACHE.toString(), + Query.SEARCH_CHAIN.toString(), Query.TIMEOUT.toString(), "trace", "tracelevel", + Query.TRACE_LEVEL.toString(), Model.MODEL, Ranking.RANKING, "collapse", "collapsesize","collapsefield", + Presentation.PRESENTATION, "pos", "streaming", "rules", RecallSearcher.recallName.toString(), "user", + CacheControl.nocachewrite.toString(), "metrics", ""); + json.put("levelZeroParameters", levelZeroParameters); + + return json.toString(); + } + } +}
\ No newline at end of file diff --git a/container-search-gui/src/main/resources/gui/_includes/css/vespa.css b/container-search-gui/src/main/resources/gui/_includes/css/vespa.css index 24cfd32cbb2..c63690581c6 100644 --- a/container-search-gui/src/main/resources/gui/_includes/css/vespa.css +++ b/container-search-gui/src/main/resources/gui/_includes/css/vespa.css @@ -109,6 +109,13 @@ section h3.section-subheading { margin-top: 0; } +header .help-title { + color: #FFC43C; + text-transform: uppercase; + font-weight: bold; +} + + .text-muted { color: #303030; } @@ -242,7 +249,7 @@ header .methodselector{ -webkit-transition:.3s; transition:.3s } - +header .intro-help:hover {background-color: #4EA2D6 !important;} header .methodselector:hover {background-color: #79B4D8;} header .button:hover {background-color: #79B4D8;} header .removeRow:hover {background-color: #79B4D8;} @@ -480,12 +487,28 @@ header .intro-copy { padding-left: 50px; transform: translateX(-50%); } + +header .intro-help { + display: inline-block; + margin-top: 15px; + width: 134px; + height: 45px; + + border-top-left-radius: 29%; + border-top-right-radius: 26%; + border-bottom-right-radius: 27%; + border-bottom-left-radius: 29%; + +} + header .intro-refresh { display: inline-block; margin-top: 15px; + margin-left: 25px; transform: translateX(-50%); } + @media (min-height: 1150px) { header .intro-down-arrow { /* Hard code top: 1150 (height of top section) - 20 (bottom) - 36 (image height) = 1094 */ diff --git a/container-search-gui/src/main/resources/gui/_includes/index.html b/container-search-gui/src/main/resources/gui/_includes/index.html index ca3302dd404..a441e302720 100644 --- a/container-search-gui/src/main/resources/gui/_includes/index.html +++ b/container-search-gui/src/main/resources/gui/_includes/index.html @@ -84,7 +84,7 @@ <option class="options" value="POST">POST</option> <option class="options" value="GET">GET</option> </select> - <input type="text" class="textbox" name="value" value="http://httpbin.org/post" id="url" size="30"> + <input type="text" class="textbox" name="value" value="http://localhost:8080/search/" id="url" size="30"> <button class="button" onclick="startSending();" id="send">Send</button> <br/> @@ -116,6 +116,30 @@ <div class="intro-refresh" onclick="refresh();" style="cursor:pointer;"> <img src="/querybuilder/img/reload.svg" height="30" width="30" /> </div> + </br> + </br> + <div id="helpbutton" class="intro-help" onclick="toggleHelp();" style="cursor:pointer;"> + <img src="/querybuilder/img/features-help.png" height="47" width="138" style="margin-left: -1px;"/> + </div> + <div id="help" style="display: none;"> + <div class="intro-param" id="help"> + </br> + <div class="help-title">Features</div> + <span> ○ Autocompletion of YQL-syntax</span> </br> + <span> ○ Drop-down lists of all valid parameters</span> </br> + <span> ○ Sending both POST and GET-requests to <i>Vespa</i></span> </br> + <span> ○ Easy access to the <a href="https://docs.vespa.ai/documentation/reference/search-api-reference.html">documentation</a> of each parameter</span> </br> + <span> ○ Conversion of POST- to GET-query</span> </br> + <span> ○ Pasting already built JSON-query</span> </br> + <span> ○ View and copy the response of queries</span> </br> + <span> ○ View the finished JSON-query as you build </span> </br> + </div> + </br> + <div class="intro-param" id="help"> + <div class="help-title">Help</div> + <span> If you find errors, spelling mistakes, faulty pieces of code or want to improve the querybuilder, please submit a pull request or create an <a href="https://github.com/vespa-engine/vespa/issues">issue</a>.</span> </br> + </div> + </div> </div> </div> </div> @@ -174,7 +198,6 @@ <script language="javascript" type="text/javascript" src="/querybuilder/editarea/edit_area/edit_area_full.js"></script> <script language="javascript" type="text/javascript"> - function fEALoaded() { $('#frame_'+window.yqlID).contents().find('.area_toolbar').hide(); var iframe = document.getElementById("frame_"+window.yqlID); @@ -184,50 +207,31 @@ - - <SCRIPT language="javascript"> - - const CONFIG = $.getJSON('/querybuilder/gui_variables.json', function(data){window.CONFIG = data;}); + const CONFIG = $.getJSON('/querybuilder/config.json', function(data){window.CONFIG = data;}); method = "POST"; var number = 0; var childno = {}; var json = JSON.parse("{}"); var searchApiReference = null; - - var possible = ["yql", "hits", "offset", "queryProfile", "nocache", "groupingSessionCache", "searchChain", "timeout", "trace","tracelevel","traceLevel", "", - , "model", "ranking", "collapse","collapsesize","collapsesize","presentation", "pos", "streaming", "rules", "recall", "user", "nocachewrite", "metrics"]; - + var possible = null; var usedProps = []; var removedIndexes = [0]; - var childrenProps = { - "model" : ["defaultIndex", "encoding", "language", "queryString", "restrict", "searchPath", "sources", "type"], - "ranking" : ["location", "features", "listFeatures", "profile", "properties", "sorting", "freshness", "queryCache", "matchPhase"], - "ranking.matchPhase" : ["maxHits", "attribute", "ascending", "diversity"], - "ranking.matchPhase.diversity" : ["attribute", "minGroups"], - "presentation" : ["bolding", "format", "summary", "template", "timing"], - "trace" : ["timestamps"], - "tracelevel" : ["rules"], - "metrics" : ["ignore"], - "collapse":["summary"], - "pos" : ["ll", "radius", "bb", "attribute"], - "streaming" : ["userid", "groupname", "selection", "priority", "maxbucketspervisitor"], - "rules" : ["off", "rulebase"] - }; - + var childrenProps = null; window.onload = function() { - // Adding variables from configuration file - if (window.CONFIG.hasOwnProperty("featurename")){ - childrenProps["ranking.features"] = window.CONFIG.featurename; - } - if (window.CONFIG.hasOwnProperty("propertyname")){ - childrenProps["ranking.properties"] = window.CONFIG.propertyname; - } - - addNewRow(); - getSearchApiReference(); + setTimeout(function(){ + possible = window.CONFIG.levelZeroParameters; + childrenProps = window.CONFIG.childMap; + if (window.CONFIG.hasOwnProperty("ranking_features")){ + childrenProps["ranking.features"] = window.CONFIG.ranking_features; + } + if (window.CONFIG.hasOwnProperty("ranking_properties")){ + childrenProps["ranking.properties"] = window.CONFIG.ranking_properties; + } + addNewRow(); + getSearchApiReference(); + }, 250); }; - var stringType = ["yql", "queryProfile", "searchChain", "model.defaultIndex", "model.encoding", "model.language", "model.queryString", "model.searchPath", "model.type", "ranking.features", "ranking.profile", "ranking.properties", "ranking.sorting", "ranking.matchPhase.diversity.attribute", "ranking.matchPhase.attribute","pos.attribute", "presentation.summary", "collapse.summary", @@ -243,6 +247,19 @@ var yqlID = "v1"; + + function toggleHelp(){ + var div = document.getElementById("help"); + var buttonDiv = document.getElementById("helpbutton"); + if (div.style.display === "none") { + div.style.display = "block"; + buttonDiv.style.backgroundColor = '#4EA2D6'; + } else { + div.style.display = "none"; + buttonDiv.style.backgroundColor = 'transparent'; + } + } + function updateFields(){ var temp = number; while (temp > 0){ @@ -260,7 +277,6 @@ temp -= 1; } } - function pasteJSON(){ var button = document.getElementById("pasteJSON"); if (button.innerHTML === "Press CMD+V"){ @@ -275,31 +291,24 @@ document.getElementById('response').addEventListener('paste', handlePaste); } } - function handlePaste (e) { var clipboardData, pastedData; - // Stop data actually being pasted into div e.stopPropagation(); e.preventDefault(); - // Get pasted data via clipboard API clipboardData = e.clipboardData || window.clipboardData; pastedData = clipboardData.getData('Text'); - // Do whatever with pasteddata alert("Converting JSON: \n\n "+pastedData); - //Removing eventlistener var oldResponse = document.getElementById('response'); var newResponse = oldResponse.cloneNode(true); oldResponse.parentNode.replaceChild(newResponse, oldResponse); - //Returning to old button and pasteJSON(); convertPastedJSON(pastedData); } - function convertPastedJSON(pastedData){ try { document.getElementById("request").innerHTML = "</br> <div class=\"intro-param\">Construct a query by adding parameters or pasting a JSON.</div>"; @@ -311,7 +320,6 @@ alert("Could not parse JSON, with error-message: \n\n"+err.message); } } - function buildFromJSON(obj,parentNo) { Object.keys(obj).forEach(function(key) { if ( typeof(eval('obj.'+key)) === "object" ) { @@ -334,7 +342,6 @@ } }); } - function copyURL(){ generateJSON(); var urlMap = dotNotate(window.json); @@ -346,7 +353,6 @@ document.body.removeChild(el); return url; } - function buildURL(map){ var url = document.getElementById("url").value + "?"; var parameters = ""; @@ -355,19 +361,15 @@ }); parameters = parameters.substr(1) return url+parameters - } - function encodeToURI(string){ string = encodeURIComponent(string); string = string.replace(/%20/g, '+'); return string; } - function dotNotate(obj,target,prefix) { target = target || {}, prefix = prefix || ""; - Object.keys(obj).forEach(function(key) { if ( typeof(obj[key]) === "object" ) { dotNotate(obj[key],target,prefix + key + "."); @@ -375,22 +377,18 @@ return target[prefix + key] = obj[key]; } }); - return target; } - function copyToClipboard(id){ id.select(); document.execCommand('copy'); clearSelection(); } - function clearSelection() { if (window.getSelection) {window.getSelection().removeAllRanges();} else if (document.selection) {document.selection.empty();} } - function chooseMethod(method) { var selectBox = document.getElementById("method"); var selectedMethod = selectBox.options[selectBox.selectedIndex].value; @@ -399,7 +397,6 @@ changeDiv(selectedMethod); } } - function changeDiv(selectedMethod){ if (selectedMethod === "GET"){ document.getElementById("request").innerHTML = '</br><textarea class=\"responsebox\" cols=70 rows=4 id=\"url2\">'+copyURL();+'</textarea>'; @@ -410,12 +407,11 @@ number = 0; changeVisibility(); let jsonString = JSON.stringify(window.json); - if (jsonString === "{}" || jsonString=== '{"":""}'){ + if (jsonString === "{}" || jsonString=== '{"":""}'){ addNewRow(); } else { buildFromJSON(window.json, 0); } - } } function stripMyHTML(html) @@ -427,7 +423,6 @@ } return tmp.innerHTML.replace('<code>','').replace('</code>',''); } - function addNewRow(key, value){ number += 1; const temp = number; @@ -443,6 +438,10 @@ newInputVal.type = "text"; newInputVal.id = "v"+temp; newInputVal.classList.add("propvalue"); + newInputVal.setAttribute("list", "val"+temp); + var newDatalist2 = document.createElement("datalist"); + newDatalist2.id = "val"+temp; + //newDatalist2.style = "display: none;"; var newButton = document.createElement("button"); newButton.id = "b"+temp; newButton.innerHTML = "-"; @@ -450,37 +449,29 @@ newButton.classList.add("removeRow"); var br = document.createElement("br"); br.id = "br"+temp - var img = document.createElement("img"); img.src = "/querybuilder/img/information.svg"; img.height = "15"; img.width = "15"; img.classList.add("information"); - var span = document.createElement("span"); span.id = "span"+temp; span.innerHTML = stripMyHTML('Choose a parameter for information'); - var a = document.createElement("a"); a.href = "#"; a.classList.add("tip"); a.id = "inf"+temp - a.appendChild(img); a.appendChild(span); - - var div = document.createElement("div"); div.id = number; div.appendChild(newInput); div.appendChild(newDatalist); - div.appendChild(a); - div.appendChild(newInputVal); + div.appendChild(newDatalist2); div.appendChild(newButton); div.appendChild(br); - var bigdiv = document.getElementById("request"); bigdiv.appendChild(div); updateFields(); @@ -489,7 +480,7 @@ newInput.value = key; keySelected(temp, value) } - if (value || value2==="false"){ + if (value || value2==="false"){ if (key === "yql"){ editAreaLoader.setValue(window.yqlID, value); } else { @@ -499,7 +490,6 @@ generateJSON(); return temp; } - function showInformation(no, key){ var a = document.getElementById("inf"+no); if(validKey(no, key)){ @@ -514,7 +504,6 @@ a.style = "visibility: hidden;" } } - function validKey(no, possibleKey){ if (contains(possible, possibleKey)){return true;} for (var key in childrenProps){ @@ -524,7 +513,19 @@ } return false; } - + function checkConfigOptions(key, no){ + var jsonID = key.replace(/\./g , "_"); + var datalist = document.getElementById("val"+no); + datalist.innerHTML = ""; + if (window.CONFIG.hasOwnProperty(jsonID)){ + var optionlist = eval("window.CONFIG."+jsonID); + optionlist.forEach(function(item){ + var option = document.createElement("option"); + option.value = item; + datalist.appendChild(option); + }); + } + } function keySelected(no, value){ var key = document.getElementById("i"+no).value; showInformation(no, key); @@ -536,6 +537,8 @@ editAreaLoader.delete_instance(window.yqlID); } var button = document.createElement("button"); + //var datalist = document.getElementById("val"+no); //Hide value-datalist + //datalist.style = "display:none;"; button.id="propb"+no button.innerHTML=" + Add property"; button.onclick = function(){addChildProp(no);}; @@ -549,6 +552,7 @@ newInputVal.type = "text"; newInputVal.id = "v"+no; newInputVal.classList.add("propvalue"); + newInputVal.setAttribute("list", "val"+no); var parent = button.parentNode; showType(newInputVal, no); if (key === "yql"){ @@ -586,11 +590,11 @@ newInputVal.type = "text"; newInputVal.id = "v"+no; newInputVal.classList.add("propvalue"); + newInputVal.setAttribute("list", "val"+no); showType(newInputVal, no); var parent = inputval.parentNode; parent.replaceChild(newInputVal, inputval); } - if (key === "yql"){ newInputVal = document.createElement("textarea"); newInputVal.id = "v"+no; @@ -619,7 +623,6 @@ if(value){ inputval.value = value; } - } } if (!validKey(no, key)){ @@ -627,14 +630,17 @@ //keyInput.style = "border-width: 1px; border-color: red;" var valueInput = document.getElementById("v"+no); valueInput.placeholder = "Possible invalid parameter"; + //Removes possible options for for former parameter + var datalist = document.getElementById("val"+no); + datalist.innerHTML = ""; } if (validKey(no, key)){ + // Check if datalist should be visible and add options + checkConfigOptions(fullKey, no); var keyInput = document.getElementById("i"+no); //keyInput.style = "border-width: 0px;" } - } - function showType(inputVal, no){ var key = document.getElementById("i"+no).value; var key = getFullName(no, key); @@ -663,7 +669,6 @@ inputVal.placeholder = ""; } } - function removeRow(no){ var div = document.getElementById(no); var key = document.getElementById("i"+no).value; @@ -676,7 +681,6 @@ updateFields(); generateJSON(); } - function removeChildRow(no){ var a = "" + no; var parentNo = a.split(".").slice(0, -1).join("."); @@ -688,30 +692,29 @@ updateChildrenFields(parentNo); generateJSON(); } - function countDots(s1) { return ( s1.match( /\./g ) || [] ).length; } - function addChildProp(no, key, value){ generateJSON(); childno[no] += 1; var temp = ""+no+"."+childno[no]; childno[temp] = 0; var parentNode = document.getElementById(no); - var newInput = document.createElement("input"); newInput.id = "i"+temp; newInput.setAttribute("list", "prop"+temp); newInput.onchange = function(){keySelected(temp);}; newInput.classList.add("input") - var newDatalist = document.createElement("datalist"); newDatalist.id = "prop"+temp; newInputVal = document.createElement("input"); newInputVal.type = "text"; newInputVal.id = "v"+temp; newInputVal.classList.add("propvalue"); + newInputVal.setAttribute("list", "val"+temp); + var newDatalist2 = document.createElement("datalist"); + newDatalist2.id = "val"+temp; var newButton = document.createElement("button"); newButton.id = "b"+temp; newButton.innerHTML = "-"; @@ -725,13 +728,11 @@ b.innerHTML = ' ↳ '; var margin = 20*(temp).length; b.style = "padding-left:"+margin+"px;"; - var img = document.createElement("img"); img.src = "/querybuilder/img/information.svg"; img.height = "15"; img.width = "15"; img.classList.add("information"); - var span = document.createElement("span"); span.id = "span"+temp; span.innerHTML = stripMyHTML('Choose a parameter for information'); @@ -746,6 +747,7 @@ div.appendChild(newDatalist); div.append(a); div.appendChild(newInputVal); + div.appendChild(newDatalist2); div.appendChild(newButton); div.appendChild(br); parentNode.appendChild(div); @@ -760,7 +762,6 @@ } return temp; } - function updateChildrenFields(parentNo){ parentKey = document.getElementById("i"+parentNo).value; var temp = parseInt(childno[parentNo]); @@ -780,7 +781,6 @@ temp -= 1; } } - function contains(a, obj) { for (var i = 0; i < a.length; i++) { if (a[i] === obj) { @@ -789,18 +789,15 @@ } return false; } - function refresh(){ document.location.reload(true); } - function generateJSON(){ json = JSON.parse("{}"); buildJSON(json, number, 0); var textarea = document.getElementById("jsonquery"); textarea.innerHTML = JSON.stringify(window.json, undefined, 4); } - function buildJSON(parent, no, thresh){ var temp = no; if (countDots(""+temp) > 0){ @@ -824,7 +821,7 @@ value = false; }} var fullKey = getFullName(temp, key); - if (contains(integerType, fullKey) || contains(longType, fullKey)){ + if (contains(integerType, fullKey) || contains(longType, fullKey)){ value = parseInt(value); value = isNaN(value) ? 0 : value; } @@ -855,13 +852,10 @@ } } } - function findUsedProps(){ usedProps = []; addUsedProps(window.number, 0); - } - function addUsedProps(no, thresh){ var temp = no; if (countDots(""+temp) > 0){ @@ -895,7 +889,6 @@ } } } - function startSending(){ if (method === "POST"){ var url = document.getElementById("url").value; @@ -912,8 +905,6 @@ window.open(url); } } - - function changeVisibility() { var x = document.getElementById("url"); var y = document.getElementById("addRow"); @@ -931,7 +922,6 @@ a.style.display = "none"; } } - function showJSON(){ var textarea = document.getElementById("jsonquery"); var copyJSON = document.getElementById("copyJSON"); @@ -950,7 +940,6 @@ copyURL.style.display = "none"; } } - function getSearchApiReference(){ var div = document.getElementById("div"); var object = document.createElement("object"); @@ -965,7 +954,6 @@ }, 20); }, 150); } - function changeInformation(no,key){ if (key===""){return "Choose a parameter for information"} if (getFullName(no,key) in childrenProps){return "Add parameters under the parent ''" + getFullName(no,key) + "'"} @@ -974,7 +962,6 @@ var tabletext = stripMyHTML(ref.getElementById(refId).nextElementSibling.outerHTML); return tabletext; } - function getFullName(no, key){ var name = key; no = ""+no; diff --git a/container-search-gui/src/main/resources/gui/_includes/search-api-reference.html b/container-search-gui/src/main/resources/gui/_includes/search-api-reference.html deleted file mode 100644 index 195c9dc2663..00000000000 --- a/container-search-gui/src/main/resources/gui/_includes/search-api-reference.html +++ /dev/null @@ -1,1011 +0,0 @@ ---- -# Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -title: "Vespa Search API reference" ---- - -<p> -All the search request parameters listed below can be set in query -profiles. The first four blocks of properties are also modeled as -query profile types. These types can be referred from query profiles -(and inheriting types) to provide type checking on the parameters. -</p><p> -These parameters often have both a full name - which includes the -path from the root query profile - and one or more abbreviated -names. Both names can be used in search requests, while only full -names can be used in query profiles. The full names are case -sensitive, while the abbreviated names are case insensitive. -</p><p> -The parameters modeled as query profiles are also available through -get methods as Java objects from the Query to Searcher components. -</p> - - - -<h2>Index</h2> - -<dt>Query</dt> -<dd> - <ul> - <li><a href="#yql">yql</a></li> - </ul> -</dd> -</dl> - -<dl> -<dt>Native Execution Parameters</dt> -<dd> - <ul> - <li><a href="#hits">hits</a> [<em>count</em>]</li> - <li><a href="#offset">offset </a>[<em>start</em>]</li> - <li><a href="#queryProfile">queryProfile</a></li> - <li><a href="#nocache">nocache</a></li> - <li><a href="#groupingSessionCache">groupingSessionCache</a></li> - <li><a href="#searchChain">searchChain</a></li> - <li><a href="#timeout">timeout</a></li> - <li><a href="#tracelevel">tracelevel</a></li> - <li><a href="#trace.timestamps">trace.timestamps</a></li> - </ul> -</dd> - -<dt>Query Model Parameters</dt> -<dd> - <ul> - <li><a href="#model.defaultIndex">model.defaultIndex</a> [<em>def-idx, default-index</em>]</li> - <li><a href="#model.encoding">model.encoding</a> [<em>encoding</em>]</li> - <li><a href="#model.filter">model.filter</a> [<em>filter</em>]</li> - <li><a href="#model.language">model.language</a> [<em>lang, language</em>]</li> - <li><a href="#model.queryString">model.queryString</a> [<em>query</em>]</li> - <li><a href="#model.restrict">model.restrict</a> [<em>restrict</em>]</li> - <li><a href="#model.searchPath">model.searchPath</a> [<em>path</em>]</li> - <li><a href="#model.sources">model.sources</a> [<em>search, sources</em>]</li> - <li><a href="#model.type">model.type</a> [<em>type</em>]</li> - </ul> -</dd> - -<dt>Ranking</dt> -<dd> - <ul> - <li><a href="#ranking.location">ranking.location</a> [<em>location</em>]</li> - <li><a href="#ranking.features">ranking.features</a> [<em>rankfeature</em>]</li> - <li><a href="#ranking.listFeatures">ranking.listFeatures</a> [<em>rankfeatures</em>]</li> - <li><a href="#ranking.profile">ranking.profile</a> [<em>ranking</em>]</li> - <li><a href="#ranking.properties">ranking.properties</a> [<em>rankproperty</em>]</li> - <li><a href="#ranking.sorting">ranking.sorting</a> [<em>sorting</em>]</li> - <li><a href="#ranking.freshness">ranking.freshness</a></li> - <li><a href="#ranking.queryCache">ranking.queryCache</a></li> - <li><a href="#ranking.matchPhase">ranking.matchPhase</a></li> - </ul> -</dd> - -<dt>Presentation</dt> -<dd> - <ul> - <li><a href="#presentation.bolding">presentation.bolding</a> [<em>bolding</em>]</li> - <li><a href="#presentation.format">presentation.format</a> [<em>format</em>]</li> - <li><a href="#presentation.template">presentation.template</a></li> - <li><a href="#presentation.summary">presentation.summary</a> [<em>summary</em>]</li> - <li><a href="#presentation.timing">presentation.timing</a></li> - </ul> -</dd> - -<dt>Grouping</dt> -<dd> - <ul> - <li><a href="#select">select</a></li> - <li><a href="#collapse.summary">collapse.summary</a></li> - <li><a href="#collapsefield">collapsefield</a></li> - <li><a href="#collapsesize">collapsesize</a></li> - </ul> -</dd> - -<dt>Geographical Searches</dt> -<dd> - <ul> - <li><a href="#pos.ll">pos.ll</a></li> - <li><a href="#pos.radius">pos.radius</a>,</li> - <li><a href="#pos.attribute">pos.attribute</a></li> - <li><a href="#pos.bb">pos.bb</a></li> - </ul> -</dd> - -<dt>Streaming Search</dt> -<dd> - <ul> - <li><a href="#streaming.userid">streaming.userid</a></li> - <li><a href="#streaming.groupname">streaming.groupname</a></li> - <li><a href="#streaming.selection">streaming.selection</a></li> - <li><a href="#streaming.priority">streaming.priority</a></li> - <li><a href="#streaming.maxbucketspervisitor">streaming.maxbucketspervisitor</a></li> - </ul> -</dd> - -<dt>Semantic Rules</dt> -<dd> - <ul> - <li><a href="#rules.off">rules.off</a></li> - <li><a href="#rules.rulebase">rules.rulebase</a></li> - <li><a href="#tracelevel.rules">tracelevel.rules</a></li> - </ul> -</dd> - -<dt>Other</dt> -<dd> - <ul> - <li><a href="#recall">recall</a></li> - <li><a href="#user">user</a></li> - <li><a href="#nocachewrite">nocachewrite</a></li> - <li><a href="#hitcountestimate">hitcountestimate</a></li> - <li><a href="#metrics.ignore">metrics.ignore</a></li> - </ul> -</dd> -</dl> - - -<h2 id="query">Query</h2> -<h3 id="yql">yql</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>String</td></tr> -<tr><td>Default</td><td>None</td></tr> -</table> -<p> -The YQL query will be parsed and executed in the backend. -Only simple YQL programs are supported, refer to -<a href="../query-language.html">YQL</a> for details. -</p> - - - -<h2 id="native-execution-parameters">Native Execution Parameters</h2> -<p> -These parameters are defined in the <code>native</code> query profile type. -</p> - - -<h3 id="hits">hits</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>count</td></tr> -<tr><td>Values</td> - <td> - A positive integer, or 0. The sum of <a href="#offset">offset</a> and - <a href="#hits">hits</a> should be lower than the configured maxoffset - value, and will be adjusted to fit. See also comment - at <code>offset</code>. - </td> -</tr> -<tr><td>Default</td><td>10</td></tr> -</table> -<p> -The maximum number of hits to return from the result set. -Must be lower than <code>maxHits</code>, which is either set in a -<a href="#queryProfile">query profile</a>, or default 400. -<!-- ToDo: link to def file or code where this is definied --> -</p> - - -<h3 id="offset">offset</h3> -<table class="table table-striped"> - <tr><td>Alias</td><td>start</td></tr> - <tr><td>Values</td> - <td> - A positive integer, including 0. - </td> - </tr> - <tr><td>Default</td><td>0</td></tr> -</table> -<p> -The index of the first hit to return from the result set. -Must be lower than <code>maxOffset</code>, which is either set in a -<a href="#queryProfile">query profile</a>, or default 1000. -<!-- ToDo: link to def file or code where this is definied --> -</p> - - -<h3 id="queryProfile">queryProfile</h3> -<table class="table table-striped"> - <tr><td>Alias</td><td><em>None</em></td></tr> - <tr><td>Values</td> - <td> - A query profile id - name:version, where version can be omitted - or partially specified, e.g "myprofile:2.1" - </td> - </tr> - <tr><td>Default</td><td><code>default</code></td></tr> -</table> -<p> -A <a href="../query-profiles.html">query profile</a> has default properties for a query. -The default query profile is named <em>default</em> - example: -<pre> -<query-profile id="default"> - <field name="maxHits">10</field> - <field name="maxOffset">1000</field> -</query-profile> -</pre> -</p> - - -<h3 id="nocache">nocache</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td> - <td> - True or false - </td> -</tr> -<tr><td>Default</td><td>false</td></tr> -</table> -<p> -Set to true to avoid the result being fetched from cache, and avoid -writing the result to cache after fetching it. -</p> - - -<h3 id="groupingSessionCache">groupingSessionCache</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td> - <td> - True or false - </td> -</tr> -<tr><td>Default</td><td>false</td></tr> -</table> -<p> -Set to true to store intermediate grouping results in the search back ends when -using multi level grouping expressions in order to speed up grouping at a -potential loss of accuracy. See the <a -href="grouping-syntax.html#sessionCache">grouping reference</a> for more -details. -</p> - - -<h3 id="searchChain">searchChain</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td> - <td> - A search chain id - name:version, where version can be - omitted or partially specified, e.g "mychain:2.1.3". - </td> -</tr> -<tr><td>Default</td><td><code>default</code></td></tr> -</table> -<p> -The search chain initially invoked when processing this query. This -search chain may invoke other chains. -</p> - - -<h3 id="timeout">timeout</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td> - <td> - Positive floating point number with an optional unit. Default unit - is seconds (s), valid unit strings are e.g. <em>ms</em> and <em>s</em>. To set - a timeout of one minute, the argument could be set to <em>60 s</em>. - Space between the number and the unit is optional. - </td> -</tr> -<tr><td>Default</td><td>Undefined, but guaranteed to be at least 5000 milliseconds. This default can be overridden by configuring timeout in a <a href="../query-profiles.html">query profile.</a></td></tr> -</table> -<p>The query timeout.</p> - - -<h3 id="tracelevel">tracelevel</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td> - <td> - Any positive number - </td> -</tr> -<tr><td>Default</td><td><em>No tracing</em></td></tr> -</table> -<p> -Set to a positive number to collect trace information for debugging -when running a query. Higher numbers give -progressively more detail on query transformations and searcher -execution. -</p> - -<h3 id="trace.timestamps">trace.timestamps</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td> - <td> - true or false - </td> -</tr> -<tr><td>Default</td><td><em>No timestamps in trace</em></td></tr> -</table> -<p> -Enable it to get timing information already at <a href="#tracelevel">tracelevel=1</a> which is useful for debugging latency spent at different components in the search chain without rendering a lot of string data which is associated with higher trace levels. -</p> - - - -<h2 id="query-model">Query Model Parameters</h2> - -<h3 id="model.defaultIndex">model.defaultIndex [<em>def-idx, default-index</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>def-idx, default-index</td></tr> -<tr><td>Values</td><td>An index name</td></tr> -<tr><td>Default</td><td><code>default</code></td></tr> -</table> -<p> -The field which is searched for query terms which doesn't explicitly specify an index. -</p> - - -<h3 id="model.encoding">model.encoding [<em>encoding</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>encoding</td></tr> -<tr><td>Values</td><td>Encoding names or aliases defined in the <a href="http://www.iana.org/assignments/character-sets">IANA character sets</a></td></tr> -<tr><td>Default</td><td>utf-8</td></tr> -</table> -<p> Sets the encoding to use when returning a result. The encodings <em>big5</em>, -<em>euc-jp</em>, <em>euc-kr</em>, <em>gb2312</em>, <em>iso-2022-jp</em> and <em>shift-jis</em> -also influences how tokenization is done in the absence of an explicit language setting. -</p><p> -The query is always encoded as UTF-8, independently of how the result will be encoded. -</p> - - -<h3 id="model.filter">model.filter [<em>filter</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>filter</td></tr> -<tr><td>Values</td><td>Any allowed collection of filter terms</td></tr> -<tr><td>Default</td><td><em>Not set</em></td></tr> -</table> -<p> -Sets a filter to be combined with the query. Typical use of a filter -is to add machine generated or preferences based filter terms to a raw -user query. The filter is parsed the same way as a query of type any, -the full syntax is available. The positive terms (preceded by +) and -phrases act as AND filters, the negative terms (preceded by -) act as -NOT filters, while the unprefixed terms will be used to RANK the -results. Unless the query has no positive terms, the filter will only -restrict and influence ranking of the result set, never cause more -matches than the query. -</p> - - -<h3 id="model.language">model.language [<em>lang, language</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>language, lang</td></tr> -<tr><td>Values</td><td>Ref. RFC 3066</td></tr> -<tr><td>Default</td><td></em>Unspecified</em></td></tr> -</table> -<p> - Informs Vespa about the natural language of the query. Please see - <a href="../linguistics.html">linguistics</a> for details. - This attribute should always be set when it is known. If this - parameter is not set, it will be guessed from the query and encoding, and - default to english if it cannot be guessed. -</p> - - -<h3 id="model.queryString">model.queryString [<em>query</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>query</td></tr> -<tr><td>Values</td><td>Any HTTP encoded legal Vespa query language string</td></tr> -<tr><td>Default</td><td><em>Not set</em></td></tr> -</table> -<p> -The <a href="simple-query-language-reference.html">Simple Vespa Query Language</a> query string -specifying which documents to match in this query. -</p> - - -<h3 id="model.restrict">model.restrict [<em>restrict</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>restrict</td></tr> -<tr><td>Values</td><td>A comma delimited list of document type names.</td></tr> -<tr><td>Default</td><td><em>Search unrestricted</em></td></tr> -</table> -<p> -The document types to restrict the search to when different document -types share the same search cluster. -</p> - - -<h3 id="model.searchPath">model.searchPath [<em>path</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>searchpath</td></tr> -<tr><td>Values</td><td><ul> - <li>searchpath::ELEMENT [';' ELEMENT]*</li> - <li>ELEMENT::PART ['/' ROW]</li> - <li>PART::EXP [',' EXP]*</li> - <li>EXP::NUM | RANGE</li> - <li>ROW::NUM</li> - <li>RANGE::'['NUM ',' NUM ' >'</li> - </ul></td></tr> -<tr><td>Default</td><td><em>Whole cluster</em></td></tr> -</table> -<p> -Specification of which path to send the query to. -Used to select which set of search nodes in the cluster should be used. -Only meant for debugging/monitoring. -</p><p> -Examples: -Note that in an indexed content cluster with flat distribution we have 1 implicit row -and each search node represents a part. -<ul> - <li>'7/3' = part 7, row 3.</li> - <li>'7/' = part 7, any row.</li> - <li>'7,1,9/0' = parts 1,7 and 9, row 0.</li> - <li>'1,[3,9>/0' = parts 1,3,4,5,6,7,8, row 0.</li> -</ul> -</p><p> -In a cluster with a multi-level dispatch setup we must specify a search path element for each level. -Lets say we have a setup with 2 mid-level dispatch groups, each containing 3 search nodes (and 3 dispatchers): -<ul> - <li>'0/;2/' = dispatch group (part) 0, any of the dispatchers (row); search node (part) 2, any row (of 1 present).</li> - <li>'0/1;2/0' = dispatch group (part) 0, dispatcher (row) 1; search node (part) 2, row 0 (of 1 present).</li> -</ul> -</p> - - -<h3 id="model.sources">model.sources [<em>search, sources</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>search, sources</td></tr> -<tr><td>Values</td><td>A comma separated list of search cluster names or other source names</td></tr> -<tr><td>Default</td><td><em>Search unrestricted</em></td></tr> -</table> -<p> -The names of the sources to search, e.g one or more search clusters and/or federated sources. -</p> - - -<h3 id="model.type">model.type [<em>type</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>type</td></tr> -<tr><td>Values</td><td>web, all, any, phrase, yql, adv (deprecated) - - refer to <a href="simple-query-language-reference.html">simple query language reference</a></td></tr> -<tr><td>Default</td><td>all</td></tr> -</table> -<p> -Selects the query language syntax of the <a href="#model.queryString">query</a> parameter. -</p> - - - -<h2 id="ranking">Ranking</h2> - -<h3 id="ranking.location">ranking.location [<em>location</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>location</td></tr> -<tr><td>Values</td><td>See <a href="../geo-search.html">Geo search</a></td></tr> -<tr><td>Default</td><td>None</td></tr> -</table> -<p> -Point (one or two dimensional) location to use as base for location ranking. -For geographical locations, it is recommended to add the location using <a href="#pos.ll">pos.ll</a> -<!-- ToDo: Why? --> -</p> - - -<h3 id="ranking.features">ranking.features.<em>featurename</em> [<em>rankfeature.</em>featurename]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>rankfeature.featurename</td></tr> -<tr><td>Values</td><td>Any string</td></tr> -<tr><td>Default</td><td>None</td></tr> -</table> -<p> -Set a rank feature to a value. This works for any key name <code>query(anyname)</code> (query features), -and also as a way to override all existing (match and document) features. -Example: <em>query=foo&ranking.features.query(userage)=42&ranking.features.fieldMatch(title)=0.65</em> -</p> - - -<h3 id="ranking.listFeatures">ranking.listFeatures [<em>rankfeatures</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>rankfeatures</td></tr> -<tr><td>Values</td><td>boolean</td></tr> -<tr><td>Default</td><td>false</td></tr> -</table> -<p> -Set to true to request <em>all</em> rank features to be calculated and returned. -The rank features will be returned in the summary field rankfeatures. -This option is typically used for MLR training, should not to be used for production. -</p> - - -<h3 id="ranking.profile">ranking.profile [<em>ranking</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>ranking</td></tr> -<tr><td>Values</td><td>Any rank profile name</td></tr> -<tr><td>Default</td><td><code>default</code></td></tr> -</table> -<p> -Sets the name of the rank profile to use for assigning relevancy scores. -The default rank profile will be used for back-ends which does not have the given rank profile. -</p> - - -<h3 id="ranking.properties">ranking.properties.<em>propertyname</em> [<em>rankproperty.propertyname</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>rankproperty.propertyname</td></tr> -<tr><td>Values</td><td>Any string</td></tr> -<tr><td>Default</td><td><em>None</em></td></tr> -</table> -<p> -Set a rank property that is passed to, and used by a feature executor for this query. -Example: <em>query=foo&ranking.properties.dotProduct.X={a:1,b:2}</em> -</p> - - -<h3 id="ranking.sorting">ranking.sorting [<em>sorting</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>sorting</td></tr> -<tr><td>Values</td><td>A valid <a href="sorting.html">sort specification</a></td></tr> -<tr><td>Default</td><td>None - order by relevance</td></tr> -</table> -<p> -A specification of how to sort the result. -Fields you want to sort on must be stored as document attributes in the index structure -by adding <a href="search-definitions-reference.html#attribute">attribute</a> to the indexing statement. -</p> - - -<h3 id="ranking.freshness">ranking.freshness</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td><code>[integer]</code>, an absolute time in seconds since epoch, or <code>now-[number]</code>, to use a time [integer] seconds into the past, or <code>now</code> to use the current time</td></tr> -<tr><td>Default</td><td>None - use the current time on each node.</td></tr> -</table> -<p> -Sets the time which will be used as <em>now</em> during execution. -</p> - - -<h3 id="ranking.queryCache">ranking.queryCache</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>boolean</td></tr> -<tr><td>Default</td><td>false</td></tr> -</table> -<p> -Turns query cache on or off. Search is a two-phase process. If the -query cache is on, the query is stored on the search nodes between the -first and second phase, saving network bandwidth and also query setup -time, at the expense of using more memory. -</p> - - -<h3 id="ranking.matchPhase">ranking.matchPhase</h3> -<p>Settings which control Vespa's behavior during the match phase. -If these are set in the query they will override any match-phase setting -in the rank profile.</p> -<dt></dt> -<dd> - <ul> - <li><a href="#ranking.matchPhase.maxHits">ranking.matchPhase.maxHits</a> the max number of hits that should be generated during the match phase</li> - <li><a href="#ranking.matchPhase.attribute">ranking.matchPhase.attribute</a> the attribute to limit matches by if more than maxHits hits will be generated</li> - <li><a href="#ranking.matchPhase.ascending">ranking.matchPhase.ascending</a> whether to keep the documents having the highest (default) or lowest values of the attribute</li> - <li><a href="#ranking.matchPhase.diversity.attribute">ranking.matchPhase.diversity.attribute</a> the attribute to use to guarantee diversity.</li> - <li><a href="#ranking.matchPhase.diversity.minGroups">ranking.matchPhase.diversity.minGroups</a> the minimum number of groups grouped by the diversity attribute.</li> - </ul> -</dd> - - -<h3 id="ranking.matchPhase.maxHits">ranking.matchPhase.maxHits</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>long</td></tr> -<tr><td>Default</td><td>If sorting and not ranking: max(10000, maxhits+maxoffset). - Otherwise: <em>none</em>.</td></tr> -</table> -<p> -The max hits the engine should attempt to produce in the match phase on each partition. -If it is determined during matching that many more hits than this will be generated, the matching will fall back to -take the best (highest or lowest) values of the attribute given by ranking.matchPhase.attribute. -</p><p> -By default, this will be turned on only when sorting is used and grouping is not. -If sorting is used, the primary sort attribute will be used as the match phase attribute if it has fast-search set. -In that case the default can be overridden by setting this value explicitly. -</p> - - -<h3 id="ranking.matchPhase.attribute">ranking.matchPhase.attribute</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>An attribute name</td></tr> -<tr><td>Default</td><td><em>none</em></td></tr> -</table> -<p> -The attribute to decide which documents are a match if the match phase -estimates that there will be more than maxHits matches. -This attribute should have fast-search set and should correlate with the order -which would be produced by a full evaluation. -</p> - - -<h3 id="ranking.matchPhase.ascending">ranking.matchPhase.ascending</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>boolean</td></tr> -<tr><td>Default</td><td>false</td></tr> -</table> -<p> -Whether the attribute should be sorted in ascending or descending (default) order -to determine which documents to keep as matches. -</p> - - -<h3 id="ranking.matchPhase.diversity.attribute">ranking.matchPhase.diversity.attribute</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>An attribute name</td></tr> -<tr><td>Default</td><td>none.</td></tr> -</table> -<p> -The attribute to be used for producing the desired diversity. -Also see <a href="search-definitions-reference.html#diversity-attribute">attribute</a>. -</p> - - -<h3 id="ranking.matchPhase.diversity.minGroups">ranking.matchPhase.diversity.minGroups</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>long</td></tr> -<tr><td>Default</td><td>none</td></tr> -</table> -<p> -The minimum number of groups that should be returned from the match phase grouped by the diversity attribute. -Also see <a href="search-definitions-reference.html#diversity-min-groups">min-groups</a>. -</p> - - - -<h2 id="presentation">Presentation</h2> - -<h3 id="presentation.bolding">presentation.bolding [<em>bolding</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>bolding</td></tr> -<tr><td>Values</td><td>boolean</td></tr> -<tr><td>Default</td><td>true</td></tr> -</table> -<p> -Whether or not to bold search terms in <a href="search-definitions-reference.html">search definition</a> -fields defined with <a href="search-definitions-reference.html#bolding">bolding: on</a> -or <a href="search-definitions-reference.html#summary">summary: dynamic</a>. -</p> - - -<h3 id="presentation.format">presentation.format [<em>format</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>format</td></tr> -<tr><td>Values</td><td> - <table class="table table-striped"> - <tr> - <td><em>No value</em> or <code><a href="default-result-format.html">default</a></code></td> - <td>The default, builtin JSON format</td> - </tr> - <tr> - <td><code><a href="default-result-format.html">json</a></code></td> - <td>Builtin JSON format</td> - </tr> - <tr> - <td><code>xml</code></td> - <td>Deprecated, builtin XML format</td> - </tr> - <tr> - <td><code><a href="page-result-format.html">page</a></code></td> - <td>Alternative deprecated XML format which is suitable for use with <a href="../page-templates.html">page templates</a>.</td> - </tr> - <tr> - <td><em>Any other value</em></td> - <td>A custom <a href="../result-rendering.html">result renderer</a> supplied by the application - </tr> - </table> - -</td></tr> -<tr><td>Default</td><td>default</td></tr> -</table> - - -<h3 id="presentation.summary">presentation.summary [<em>summary</em>]</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td>summary</td></tr> -<tr><td>Values</td><td> - The name of the <a href="../document-summaries.html#summary-classes-in-queries">summary class</a> - used to select fields in results. -</td></tr> -<tr><td>Default</td><td>The default summary class of the search definition.</td></tr> -</table> - - -<h3 id="presentation.template">presentation.template</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>Any id specification of a deployed page template.</td></tr> -<tr><td>Default</td><td></td></tr> -</table> -<p> -The id of the page template to use for this result. This should be used with the -<a href="page-result-format.html">page</a> result format. -</p> - - -<h3 id="presentation.timing">presentation.timing</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>boolean</td></tr> -<tr><td>Default</td><td>false</td></tr> -</table> -<p> -Whether a result renderer should try to add optional timing information -to the rendered page. -</p> - - - -<h2 id="">Grouping and Aggregation</h2> - -<h3 id="select">select</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>A valid grouping specification.</td></tr> -<tr><td>Default</td><td>No grouping</td></tr> -</table> -<p> -Requests specific multi-level result set statistics and/or hit groups to be returned in the result. -Fields you want to retrieve statistics or hit groups for must be stored as document attributes -in the index structure by adding attribute to the indexing statement. -See the <a href="../grouping.html">grouping guide</a>. -</p> - - -<h3 id="collapsefield">collapsefield</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>Any document summary field name</td></tr> -<tr><td>Default</td><td>No field collapsing</td></tr> -</table> -<p> -Collapse (i.e. aggregate) results using this field. -Collapsing is run in the container, not content node level. -Define a <em>collapsefield</em> to remove duplicates if the corpus has few duplicates - -this is more efficient than using <a href="#select">grouping</a>. -Otherwise, use grouping. -</p> - - -<h3 id="collapsesize">collapsesize</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>A positive integer</td></tr> -<tr><td>Default</td><td>1</td></tr> -</table> -<p>The number of hits to keep in each collapsed bucket</p> - - -<h3 id="collapse.summary">collapse.summary</h3> -<table class="table table-striped"> - <tr><td>Alias</td><td></td></tr> - <tr><td>Values</td><td>A valid name of a document summary class.</td></tr> - <tr><td>Default</td><td>Use default summary or attributes.</td></tr> -</table> -<p>Use this summary class to fetch the field used for collapsing.</p> - - - -<h2 id="geographical-searches">Geographical Searches</h2> - -<h3 id="pos.ll">pos.ll</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td> - <td>Position given in latitude and longitude - example: <em>S22.4532;W123.9887</em> - Refer to <a href="search-definitions-reference.html#type:position">position field</a> - for format specification.</td> -</tr> -<tr><td>Default</td><td>None</td></tr> -</table> - - -<h3 id="pos.radius">pos.radius</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td> - Radius of the circle used for filtering. Valid units of measurement are km, m and mi. Examples: - <ul> - <li>pos.radius=100m</li> - <li>pos.radius=42mi</li> - <li>pos.radius=4km</li> - </ul> - One can also specify just a number (internal units, micro-degrees), but this is not recommended. -</td></tr> -<tr><td>Default</td><td>50km</td></tr> -</table> - - -<h3 id="pos.bb">pos.bb</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td> - Bounding box for positions, given as latitude and longitude boundaries. - The four boundaries must be specified as N, S, E, W, with degrees as - a decimal fraction. Degrees south of equator or west of Greenwich are - input as negative numbers. Examples: - <ul> - <li>n=37.44899,s=37.3323,e=-121.98241,w=-122.06566</li> - <li>s=40.183868,w=-74.819519,n=40.248291,e=-74.728798</li> - </ul> -</td></tr> -<tr><td>Default</td><td>None</td></tr> -</table> - - -<h3 id="pos.attribute">pos.attribute</h3> -<table class="table table-striped"> - <tr><td>Alias</td><td></td></tr> - <tr><td>Values</td><td>Any attribute that has zcurve encoded positions as a long attribute.</td></tr> - <tr><td>Default</td><td>Random choice among the ones declared as position in the searchdefinition.</td></tr> -</table> -<p> -Which attribute to use for the position. Can be both single- or multi-value. -</p> - - - -<h2 id="">Streaming Search</h2> -<p> -The features in this section applies to <a href="../streaming-search.html">streaming search</a> only. -</p> - -<h3 id="streaming.userid">streaming.userid</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>An integer in decimal notation in the range [0, 2^64></td></tr> -<tr><td>Default</td><td>None</td></tr> -</table> -<p> -Restricts streaming search to only stream through documents with document ids having the n=<number> -modifier and the userid part matches the supplied value. This can be used for grouping documents on a 64 bit integer. -</p> - - -<h3 id="streaming.groupname">streaming.groupname</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>A string</td></tr> -<tr><td>Default</td><td>None</td></tr> -</table> -<p> -Restricts streaming search to only stream through documents with document ids having the g=<groupname> -modifier and the groupname part matches the supplied value. This can be used for grouping documents on a string. -</p> - - -<h3 id="streaming.selection">streaming.selection</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>A string</td></tr> -<tr><td>Default</td><td>None</td></tr> -</table> -<p> -Restricts streaming search using a <a href="document-select-language.html">document selection</a>. -This can be used for selecting a subset of documents based on an advanced expression. -</p> - - -<h3 id="streaming.priority">streaming.priority</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td><a href="services.html#load-types">Priority class</a></td></tr> -<tr><td>Default</td><td>VERY_HIGH</td></tr> -</table> -<p> -Priority of the streaming search visitor. Having a high priority visitor helps maintain low latencies -even when the system is under load. -</p> - - -<h3 id="streaming.maxbucketspervisitor">streaming.maxbucketspervisitor</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>int</td></tr> -<tr><td>Default</td><td>1 (if ordering is set), or infinite</td></tr> -</table> -<p> -If set, visit only this many buckets at a time. -Combine with ordering to reduce visiting time for large users/groups. -</p> - - - -<h2 id="semantic-rules">Semantic Rules</h2> -<p> -Refer to <a href="semantic-rules.html">semantic rules</a>. -</p> - -<h3 id="rules.off">rules.off</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>Boolean</td></tr> -<tr><td>Default</td><td>True</td></tr> -</table> -<p>Turn rule evaluation off for this query</p> - - -<h3 id="rules.rulebase">rules.rulebase</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>String</td></tr> -<tr><td>Default</td><td>A rule base name</td></tr> -</table> -<p>The name of the rule base to use for these queries</p> - - -<h3 id="tracelevel.rules">tracelevel.rules</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>int</td></tr> -<tr><td>Default</td><td>1-5 (?)</td></tr> -</table> -<p> -The amount of rule evaluation trace output to show, higher number means more details. -This is useful to see a trace from rule evaluation -without having to see trace from all other searchers at the same time. -</p> - - - -<h2 id="other">Other</h2> - -<h3 id="recall">recall</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>Any allowed collection of recall terms</td></tr> -<tr><td>Default</td><td>No recall</td></tr> -</table> -<p> -Sets a recall parameter to be combined with the query. -This is identical to <a href="#model.filter">filter</a>, -except that recall terms are not exposed to the ranking framework and thus not ranked. -As such, one can not use unprefixed terms; they must either by positive or negative. -</p> - - -<h3 id="user">user</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>A string</td></tr> -<tr><td>Default</td><td>None</td></tr> -</table> -<p> -The id of the user making the query. The contents of the argument are made available to the search chain, -but it triggers no features in Vespa apart from being propagated to the access log. -</p> - - -<h3 id="nocachewrite">nocachewrite</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>Boolean</td></tr> -<tr><td>Default</td><td>False</td></tr> -</table> -<p>Set to true to avoid the result being written to cache when fetched.</p> - - -<h3 id="hitcountestimate">hitcountestimate</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>Boolean</td></tr> -<tr><td>Default</td><td>False</td></tr> -</table> -<p>Make this an estimation query. -No hits will be returned, and total hit count will be set to an estimate of what executing -the query as a normal query would give. -</p> - -<h3 id="metrics.ignore">metrics.ignore</h3> -<table class="table table-striped"> -<tr><td>Alias</td><td></td></tr> -<tr><td>Values</td><td>Boolean</td></tr> -<tr><td>Default</td><td>False</td></tr> -</table> -<p>Ignore metric collection for this query request, useful for warm up queries</p> diff --git a/container-search-gui/src/main/resources/gui/editarea/edit_area/plugins/autocompletion/autocompletion.js b/container-search-gui/src/main/resources/gui/editarea/edit_area/plugins/autocompletion/autocompletion.js index d6984f59899..5531a2a4f69 100644 --- a/container-search-gui/src/main/resources/gui/editarea/edit_area/plugins/autocompletion/autocompletion.js +++ b/container-search-gui/src/main/resources/gui/editarea/edit_area/plugins/autocompletion/autocompletion.js @@ -480,7 +480,10 @@ var EditArea_autocompletion= { {
var line= "<li><a href=\"#\" class=\"entry\" onmousedown=\"EditArea_autocompletion._select('"+ results[i][1]['replace_with'].replace(new RegExp('"', "g"), """) +"');return false;\">"+ results[i][1]['comment'];
if(results[i][0]['prefix_name'].length>0)
- line+='<span class="prefix">'+ results[i][0]['prefix_name'] +'</span>';
+ var value = results[i][0]['prefix_name'];
+ value = (value == undefined) ? "" : value;
+ if (value == 'SOURCES' || value == ','){value = 'Source'}
+ line+='<span class="prefix">'+ value +'</span>';
line+='</a></li>';
lines[lines.length]=line;
}
diff --git a/container-search-gui/src/main/resources/gui/editarea/edit_area/reg_syntax/yql.js b/container-search-gui/src/main/resources/gui/editarea/edit_area/reg_syntax/yql.js index e4e9cd3b32d..0a7dae862f3 100755 --- a/container-search-gui/src/main/resources/gui/editarea/edit_area/reg_syntax/yql.js +++ b/container-search-gui/src/main/resources/gui/editarea/edit_area/reg_syntax/yql.js @@ -1,6 +1,19 @@ /**
* Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
*/
+function getSources(bool){
+ var options = [];
+ if (window.CONFIG.hasOwnProperty("model_sources")){
+ var sources = window.CONFIG.model_sources;
+ for (i in sources){
+ option = [sources[i]];
+ options.push(option);
+ }
+ if (bool == true){options.push(["*"])}
+ }
+ return options;
+}
+
editAreaLoader.load_syntax["yql"] = {
'DISPLAY_NAME' : 'YQL'
,'QUOTEMARKS' : {1: "'", 2: '"', 3: '`'}
@@ -74,9 +87,23 @@ editAreaLoader.load_syntax["yql"] = { ['DESC','DESC'],['ASC','ASC'],['ALL','ALL'], ['GROUP','GROUP'],
['RANGE','RANGE'],['EACH','EACH'],['OUTPUT','OUTPUT'],
['SUM','SUM'],['LIMIT','LIMIT'],['OFFSET','OFFSET'],
- ['TIMEOUT','TIMEOUT'],
- ]
+ ['TIMEOUT','TIMEOUT']
+ ]
+ }
+ },
+ "sources": { // the name of this definition group. It's posisble to have different rules inside the same definition file
+ "REGEXP": { "before_word": "[^a-zA-Z0-9_]|^" // \\s|\\.|
+ ,"possible_words_letters": "[a-zA-Z0-9_]+"
+ ,"letter_after_word_must_match": "[^a-zA-Z0-9_]|$"
+ ,"prefix_separator": " "
+ }
+ ,"CASE_SENSITIVE": false
+ ,"MAX_TEXT_LENGTH": 50 // the maximum length of the text being analyzed before the cursor position
+ ,"KEYWORDS": {
+ 'SOURCES' : getSources(true) ,
+ ',' : getSources(false)
}
}
+
}
};
diff --git a/container-search-gui/src/main/resources/gui/gui_variables.json b/container-search-gui/src/main/resources/gui/gui_variables.json deleted file mode 100644 index 1b5f411611a..00000000000 --- a/container-search-gui/src/main/resources/gui/gui_variables.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "propertyname" : ["propertyname"], - "featurename" : ["featurename"] -} diff --git a/container-search-gui/src/main/resources/gui/img/features-help.png b/container-search-gui/src/main/resources/gui/img/features-help.png Binary files differnew file mode 100644 index 00000000000..65702f8b91f --- /dev/null +++ b/container-search-gui/src/main/resources/gui/img/features-help.png diff --git a/container-search-gui/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java b/container-search-gui/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java deleted file mode 100644 index ec515a1bf4a..00000000000 --- a/container-search-gui/src/test/java/com/yahoo/search/query/gui/GUIHandlerTest.java +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.search.query.gui; - -import com.yahoo.application.Networking; -import com.yahoo.application.container.JDisc; -import com.yahoo.application.container.handler.Request; -import com.yahoo.application.container.handler.Response; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; - -import static org.junit.Assert.assertTrue; - - -/** - * @author Henrik Høiness - */ - -public class GUIHandlerTest { - - private JDisc container; - - @Before - public void startContainer() { - container = JDisc.fromServicesXml(servicesXml(), Networking.enable); - } - - @After - public void stopContainer() { - /* - try { - Thread.sleep(100_000); - } catch (InterruptedException e) { - e.printStackTrace(); - }*/ - container.close(); - } - - @Test - public void testRequest() throws Exception { - assertResponse("/querybuilder/", "<!-- Copyright 2018 Yahoo Holdings.","text/html; charset=UTF-8", 200); - } - - @Test - public void testContentTypes() throws Exception{ - assertResponse("/querybuilder/_includes/css/vespa.css", "/**","text/css; charset=UTF-8", 200); - assertResponse("/querybuilder/js/agency.js", "/*!","application/javascript; charset=UTF-8", 200); - assertResponse("/querybuilder/img/reload.svg", "<?xml","image/svg+xml; charset=UTF-8", 200); - assertResponse("/querybuilder/img/Vespa-V2.png", null,"image/png; charset=UTF-8", 200); - } - - @Test - public void testInvalidPath() throws Exception{ - assertResponse("/querybuilder/invalid_filepath", "{\"error-code\":\"NOT_FOUND\",\"message\":\"Nothing at path","application/json; charset=UTF-8", 404); - } - - - private void assertResponse(String path, String expectedStartString, String expectedContentType, int expectedStatusCode) throws IOException { - assertResponse(Request.Method.GET, path, expectedStartString,expectedContentType, expectedStatusCode); - } - - private void assertResponse(Request.Method method, String path, String expectedStartString, String expectedContentType, int expectedStatusCode) throws IOException { - Response response = container.handleRequest(new Request("http://localhost:8080" + path, new byte[0], method)); - Assert.assertEquals("Status code", expectedStatusCode, response.getStatus()); - Assert.assertEquals(expectedContentType, response.getHeaders().getFirst("Content-Type")); - if(expectedStartString != null){ - assertTrue(response.getBodyAsString().startsWith(expectedStartString)); - } - } - - private String servicesXml() { - return "<jdisc version='1.0'>\n" + - " <handler id='com.yahoo.search.query.gui.GUIHandler'>\n" + - " <binding>http://*/querybuilder/*</binding>\n" + - " </handler>\n" + - " <http>\n" + - " <server id='default' port='8080'/>\n" + - " </http>\n" + - "</jdisc>"; - } - -}
\ No newline at end of file |