The problem is, if the long field has value 120450, 120445, 120656. Please find the query below.
{"from":0,"size":10,"query":{"nested":{"query":{"bool":{"must":[{"querystring":{"query":"120","fields":["alist.articleId"]}}]}},"path":"alist"}}}_
The response should return all the three documents which has partial match for 120. Is it possible to achieve this in long or a numeric field ?
For partial matching on numerics, you can store them as string values.
Now, you can use either of the following
use edgeNGram tokenizer
use prefix query, your field needs to be marked not_analyzed in this case
Related
How can I filter out an empty string in a field?
I have tried search.ismatch() using "filter" option and regex using "search" option, but none of them worked.
As commented by juunas, $filter=FieldName ne '' should do the trick for you if your field is of type Edm.String. In addition if you want to filter out empty collection fields, you can do something like $filter=FieldName/any()
Also, to clarify search.ismatch() is a way to include search ranking in filter expressions. The matching criteria takes affect only on documents that satisfy the filter expression. For more details, look at https://learn.microsoft.com/en-us/rest/api/searchservice/odata-expression-syntax-for-azure-search
I need to create a long list of complex strings, containing the data of different fields in different places to create explanatory reports.
The only way I conceived, in Access 2010, is to save text parts in a table, together with field names to be used to compose the string to be shown (see line1 expression in figure). Briefly:
//field A contain a string with a field name:
A = "[Quantity]"
//query expression:
=EVAL(A)
//return error instead the number contained in field [Quantity], present in the query dataset
I thought doing an EVAL on a field (A), to obtain the value of the field (B) which name is contained in field A. But seems not working.
Any way exist?
Example (very simplified):
Sample query that EVAL a field containing other field names to obtain the value of the fields
Any Idea?
PS: Sorry for my english, not my mothertongue.
I found a interesting workaround in another forum.
Other people had same problem using EVAL, but found that it is possible to substitute a string with a field contents using REPLACE function.
REPLACE("The value of field Quantity is {Quantity}";"{Quantity}";[Quantity])
( {} are used only for clarity, not needed if one knows that words to be substituted do not compare in the string). Using this code in a query, and nesting as many REPLACE as many different fields one want to use:
REPLACE(REPLACE("<Salutation> <Name>";"<Salutation>";[Salutation]);"<Name>";[Name])
it is possible to embed fields name in a string and substitute them with the current value of that field in a query. Of course the latter example can be done more simply with a concatenation (&), but if the string is contained in a field instead that hardcoded, it can be linked to records as needed.
REPLACE(REPLACE([DescriptiveString];"[Salutation]";[Salutation]);"[Name]";[Name])
Moreover, it is possibile to create complex strings context-based as:
REPLACE(REPLACE(REPLACE("{Salutation} {Name} {MaidenName}";"{Salutation}";[Salutation]);"{Name}";[Name]);"{MaidenName}";IIF(Isnull([MaidenName]);"";[MaidenName]))
The hard part is to enumerate all the field's placeholders one wants to insert in the string (like {Quantity},{Salutation}, {Name}, {MaidenName}) in the REPLACE call, while with EVAL one would avoid this boring part, if only it was working.
Not as neat as I would, but works.
I am using FieldCacheTermsFilter to filter out the results matching the field value as below.
Filter filter = new FieldCacheTermsFilter("city","toronto");
This works perfectly fine, whereas it doesn't work if the value has a space or special character in between like below.
Filter filter = new FieldCacheTermsFilter("city","new york");
Filter filter = new FieldCacheTermsFilter("type","b&b");
Is there way I can achieve this with any other filter.
PS: I am using FieldCacheTermsFilter for the reason that i want to search exactly on the word matching just "toronto" and not "greater toronto". I tried using TermFilter which extracts all the records containing toronto.
Your problem isn't the TermsFilter, it's your analyzer. Analysis should suit your needs for the field.
If you need to get exact matches on a whole field, you should index it as a StringField (or use KeywordAnalyzer, or set the field as untokenized). If you index with StandardAnalyzer, there is simply no good way to do what you are asking.
I need to check if a string is in the format '4.3.10'.
For example, If compare the strings 'AS45' or '456' or '4.1' with the above pattern, I should get a error message or boolean false.
Use the Postgres SIMILAR TO statement for pattern matching. In a query, the pattern matcher would like like this:
SELECT * FROM table WHERE column SIMILAR TO '[0-9]\.[0-9]\.[0-9][0-9]';
You can change the ranges within the brackets as needed.
http://www.postgresql.org/docs/current/static/functions-matching.html
We can use 'SIMILAR TO' operation.
IF we want to match more than one pattern at the same time use the following query.
SELECT * FROM table WHERE column SIMILAR TO '(.._|.|_|..|..|_..|_..|_..|..__)';
Separate each pattern with an 'OR' (|) operator.
In the above query I am comparing 9 different patterns.
is it possible to concatenate string to solr field while we are searching
Example:
localhost:8983/solr/collection1/select?q=item_type%3Apostings&wt=json&indent=true
now i have one field id i need to append text "locality_" before every id value.so that i need not to to for loop on large data set.
With Solr 4.0 SOLR-2444 enables to define alias to a field, apply transformer to the value.
I have not used the above, but you can surely explore on the above either by modifying the value with function query add with constant value or defining a Custom Transformer to apply on a alias field.