The query parameter takes a query string in the same format that an end user would use. The operators specified by syntax-operators are used to parse that query string into a query object.
By default, non-fielded keywords are mapped to the special query field, which matches all contents unless specified otherwise in the query mapping, the source, or the collection.
XML message:
<QuerySearch xmlns="urn:/velocity/types">
<query>"search engine" OR test</query>
<sources>my-new-collection</sources>
</QuerySearch>
In C#:
QuerySearch qs = new QuerySearch();
qs.sources = COLLECTION;
qs.query = "\"some main document\" OR (first and test)";
qs.syntaxrepositorynode = "custom";
qs.syntaxoperators = "AND and () CONTAINING CONTENT %field%: + NEAR - NOT NOTCONTAINING NOTWITHIN OR0 quotes regex stem THRU BEFORE FOLLOWEDBY weight wildcard wildchar WITHIN WORDS site less-than less-than-or-equal greater-than greater-than-or-equal equal range";
qs.querymodificationmacros = "some_macro_here";
qs.aggregate = true;
qs.aggregatemaxpasses = 3;
qs.authorizationpassword = "password";
qs.authorizationusername = "username";
qs.authorizationrights = "acl1\nacl2\nacl3";
qs.fetch = false;
qs.fetchtimeout = 60000;
qs.num = 200;
qs.nummax = 500;
qs.nummaxSpecified = true;
qs.numoverrequest = 1.3;
qs.numpersource = 25;
qs.numpersourceSpecified = true;
qs.start = 0;
qs.outputboldcontents = "title snippet";
qs.outputboldcontentsexcept = false;
qs.outputboldcontents = "";
qs.outputboldcontentsexcept = true;
qs.outputboldclassroot = "myClass";
qs.outputcachereferencesSpecified = false;
qs.outputcachedataSpecified = true;
qs.outputcontents = "contentA contentB";
qs.outputcontentsmode = QuerySearchOutputcontentsmode.list;
qs.outputcontentsmode = QuerySearchOutputcontentsmode.except;
qs.outputcontentsmode = QuerySearchOutputcontentsmode.defaults;
qs.outputduplicates = true;
qs.outputduplicatesSpecified = true;
qs.outputkey = true;
qs.outputkeySpecified = true;
qs.outputscore = true;
qs.outputscoreSpecified = true;
qs.outputshingles = true;
qs.outputshinglesSpecified = true;
qs.outputsortkeys = true;
qs.outputsortkeysSpecified = true;
qs.outputsummary = true;
qs.outputsummarySpecified = true;
qs.rankdecay = 0.5;
qs.rankdecaySpecified = true;
qs.debug = true;
qs.profile = true;
QuerySearchResponse qsr = port.QuerySearch(qs);
In Java:
QuerySearch qs = new QuerySearch();
qs.setSources(COLLECTION);
qs.setQuery("\"some main document\" OR (first and test)");
QuerySearchResponse qsr = port.querySearch(qs);
The following lists highlights some common query-search attributes that are used to control the number of results that are returned, and how the values of those attributes interact:
For example, to get back the n-10 results beyond the first 10, set start=10, num=n-10, and num-max=n. To get back results 55 to 75, set start=54, num=20, and num-max=74.
The remainder of this section provides code examples for some common tasks associated with submitting queries and processing query results.
Collapsing documents and bins in C#:
QuerySearch qs = new QuerySearch();
qs.collapsebinning = true;
qs.collapsebinningSpecified = true;
qs.collapsenum = 10;
qs.collapsenumSpecified = true;
qs.collapsesortxpaths = new QuerySearchCollapsesortxpaths();
qs.collapsesortxpaths.sort = new sort[1];
qs.collapsesortxpaths.sort[0] = new sort();
qs.collapsesortxpaths.sort[0].order = sortOrder.descending;
qs.collapsesortxpaths.sort[0].xpath = "$some_field";
qs.collapsexpath = "$key";
Spelling correction when querying in C#:
QuerySearch qs = new QuerySearch();
qs.spellingconfiguration = new QuerySearchSpellingconfiguration();
qs.spellingconfiguration.spellingcorrectorconfiguration = new spellingcorrectorconfiguration();
qs.spellingconfiguration.spellingcorrectorconfiguration.spellingcorrectorfield = new spellingcorrectorfield[1];
qs.spellingconfiguration.spellingcorrectorconfiguration.spellingcorrectorfield[0] = new spellingcorrectorfield();
qs.spellingconfiguration.spellingcorrectorconfiguration.spellingcorrectorfield[0].dictionary = "default";
qs.spellingconfiguration.spellingcorrectorconfiguration.spellingcorrectorfield[0].field = "myField1|myField2";
qs.spellingconfiguration.spellingcorrectorconfiguration.spellingcorrectorfield[0].stemmer = "case";
qs.spellingenabled = true;
QuerySearchResponse qsr = port.QuerySearch(qs);
queryresults qr = qsr.queryresults;
if (qr.spellingcorrection != null)
{
String correctedQuery =
qr.spellingcorrection.@string;
query q = qr.spellingcorrection.query;
}
Old-style wildcard/regex expansion when querying in C#:
QuerySearch qs = new QuerySearch();
qs.dictexpanddictionary = "default";
qs.dictexpandmaxexpansions = 100;
qs.dictexpandmaxexpansionsSpecified = true;
qs.dictexpandregexenabled = true;
qs.dictexpandregexenabledSpecified = true;
qs.dictexpandstemenabled = true;
qs.dictexpandstemenabledSpecified = true;
qs.dictexpandstemstemmers = "case";
qs.dictexpandwildcarddelanguage = true;
qs.dictexpandwildcarddelanguageSpecified = true;
qs.dictexpandwildcardenabled = true;
qs.dictexpandwildcardenabledSpecified = true;
qs.dictexpandwildcardminlength = 1;
qs.dictexpandwildcardminlengthSpecified = true;
qs.dictexpandwildcardsegmenter = "mixed";
Enhanced wildcard/regex expansion when querying in C#:
QuerySearch qs = new QuerySearch();
qs.termexpandmaxexpansions = 25;
qs.termexpandmaxexpansionsSpecified = true;
qs.termexpanderrorwhenexceedslimit = true;
qs.termexpanderrorwhenexceedslimitSpecified = true;
qs.termexpanderrorwhenexceedslimit = false;
qs.termexpanderrorwhenexceedslimitSpecified = true;