I am using the Azure Search C# SDK version 5.0.1. I am trying to perform a simple query that will search a field for a value that starts with something. It would be equivalent to the SQL query of Select * From mytable Where myproperty = 'val%'. According to the Simple Query Syntax documentation (located here) this should be possible using a wildcard. I cannot figure out how to get it working. I have tried to populate the Filter property of the SearchParameters in the following ways:
"fieldname eq 'val*'" Doesn't work
"fieldname eq 'val\.*'" Doesn't work
"search.in(filename, 'val*')" Doesn't work
Does anyone know of a way to perform wildcard searches using Azure Search .NET SDK with simple query syntax?
Wildcards work in searches, not filters. You need to use it in the searchText parameter, not the Filter parameter.
Related
On salesforce i saw apps which are able to run CONTAINS queries. Even the basic list filter functionality on object list allows the CONTAINS filtering.
Using SOSL i tried the following:
List<List<SObject>> searchList = [FIND '*ben* AND *berlin*' IN ALL FIELDS
RETURNING Account(Name)];
I have an account name "BigBen" in "Berlin". I am not able to find this account using upper SOSL call. I tried different combinations, but no success. How do i do SOSL calls with CONTAINS?
Using the basic list filtering i am able to use CONTAINS with "ben", it gives me the expected results.
Unlike SOQL which supports wildcards anywhere in the search term using the LIKE comparison operator, SOSL does not allow the use wildcards at the beginning of a search term (a "starts with" search).
In this case, where you are searching only one sObject, you might do better with SOQL.
There are solr query strings available from the log ,and the intent is to analyze the query to find out number fqs ,terms etc. Is there any api/parser available in solr/lucene to parse the entire query string and get the terms used ,filters used ,languages used ,fields used etc. Looked at QueryParser provided by lucene ,but it doesn't seem to help.
Example simple query string:
q=*:*&facet.field=Language&facet=true&f.Language.facet.limit=101&rows=0&sort=score desc,DefaultRelevance desc&fl=xxNonexx&bmf=50&wt=xml
You can use the SolrRequestParsers.parseQueryString() method to convert the string into Solr Params. Here's a link to documentation for it.
Below is an example.
String queryString = "q=*:*&facet.field=Language&facet=true&f.Language.facet.limit=101&rows=0&sort=score desc,DefaultRelevance desc&fl=xxNonexx&bmf=50&wt=xml";
MultiMapSolrParams solrParams = SolrRequestParsers.parseQueryString(String);
The code resides in the solr-core library, so you may need to add it.
I think you're not really looking for a parser but for a way to debug your query. Fortunately Solr has a debug parameter that you can use for such purpose as explained here. For instance you can add to your query:
q=*:*&facet.field=Language&facet=true&f.Language.facet.limit=101&rows=0&sort=score desc,DefaultRelevance desc&fl=xxNonexx&bmf=50&debug=true&wt=xml
I need to query SOLR index using a WHERE clause -
When I try with AND clause its not working
NOT WORKING
category:2 AND -document_type:category
WORKING
category:2 -document_type:category
Which is the correct syntax?
You could try to pass -(document_type:category) as a filter query (fq=-(document_type:category)). Should work that way and is also faster because of optimized caches on filter queries.
Also tested your specific case, but it also works for me in a regular query.
I am trying to query sol using solrnet.
I am looking to boost the query by a record's property.
My query then looks like this:
/select?fl=QualityScore,score&q={!boost+b=sum(1,log(sum(1,QualityScore)))+v=$qq}&qq="qome query"
Is there a way to do this using SolrNet?
PS - I already looked at SolrNet queries with boost functions and I dont see the same result when I use 'bf'.
Mauricio's pointer is what helped me in this case.
Local Params
I am trying to make a query in solr.net that generates a solr query with a filter query with more than one term in it e.g.: fq=Size:(4 large)
However, when I pass ?f_Size=(4 large) in the query string to the SolrNet sample app (found here: http://code.google.com/p/solrnet/downloads/list), no results are found.
Looking at the logs, I can see that the filter query generated is fq=Size:"\(4+large\)" so it makes sense that no results are found.
Is there a way in SolrNet to generate a filter query with more than one term?
Where the filter queries are built, try replacing Query.Field(...).Is(...) with Query.Simple(...) (you have to build the query yourself). See the wiki for reference.