Is there a way to search documents by trimmed values - faunadb

I have a collection containing documents of users with contact numbers. For instance a contact number can look like this '082 807 0949' or this '082 8070 949'. I want to fetch user by contact number which is trimmed. Since the match function does a check on exact values, my query returns nothing.
Is there a way I can first trim the document data before I do the search or is there way I can create an index which would trim all the contact numbers for the index.
See code below the query that returns no data:
q.Get(
q.Match(q.Index('guests_by_contact_number'), '0828070949')
)

ReplaceStr($phone, " ", "") is the ticket. For instance:
db> ReplaceStr("082 8070 949", " ", "")
'0828070949'
You can combine this with a binding to trim the phone number at write time. By making the term over the binding you can search using the normalized phone number.

Related

extract text from documents like PAN and Aadhaar

I am using cloud google vision API to extract text from Aadhaar and PAN. How can I get exact user details like name, father's name, and address?
Raw Data
ଭାରତ ସରକାର
Government of India
ଜିତ୍ୟାନନ୍ଦ ଖେମୁକୁ
NITYANANDA KHEMUDU
ପିତା : ସୀତାରାମ ଖେମୁକୁ
Father: Sitaram Khemudu
ଜନ୍ମ ତାରିଖ / DOB : 01.07.1999
ପୁରୁଷ / Male
ମୋ ଆଧାର, ମୋ ପରିଚୟ
I have built 5-6 OCR till date like aadhar, pan, ITR, Driving Linces etc., using google cloud vision API, I think you are looking for response like
{"pan_card_no":"ECXXXXXX123",
"name":"fshksj"
}
to get such response you need to built your own logic, here are some logic's i can share with you
Perform OCR on your document using Google_cloud_vision API and store that response into one array (Goggle gives logic line by line)
Like in above case if you want to grab DOB first you can build logic like i) if "DOB" in (list of item) then grab the numeric values
To get the name what you can do is dropping the unnecessary items from list by if using if condition like (if "India" in i) or (if i.isdigit()) then drop it likewise you can drop the unnesseary items from main list to get the Name
to grab the Address what you can do is, 95% of the time address come with pincode at last, so what you can do is treat pincode as a last index of address and look of "Address" kind of keyword then add all the elements from "Add keyword index" to "pincode index" ( this can be easily done in list) to validate whether the pincode is valid or not you can use library like Pyzipin
There are multiple conditions that you can use, above are the very basic one i mentioned, if you need any specific logic then then you can ask me

How to deal with arrays in the QuickMap function in Flowgear

I need to match one field called defaultAddress in NetSuite into several fields (Address1, city, State, PostCode and Country) in Autotask.
IIF(ISEMPTY({defaultAddress}), "No Address is provided",SPLIT(REPLACE({defaultAddress}, "", ","), ","))
I have used several Quickmap functions and I have successfully split the original default address into an array. But I can't use array[index] to get a certain part.
Is there a better way that I can split the address and match it with the corresponding fields?
Thanks
Quickmap is backed by VB script, so the way to use indexing is (0) instead of [0] for C#.
You can use:
IIF(ISEMPTY({defaultAddress}), "No Address is provided",SPLIT({defaultAddress}, ","))(0)
IIF(ISEMPTY({defaultAddress}), "No Address is provided",SPLIT({defaultAddress}, ","))(1)
You can see a simple example here: https://flowgear.me/s/b4Dngzi

In SSRS Report Builder, the results that are being delivered are in a very long string, I need to be able to extract certain substrings

One result, under one field of data contains the below, it's extremely long. I need to be able to pull out certain substrings into seperate columns.
Desired Result:
1) email addresses that it's being sent to, identified by "TO": gregory.dettorre#cardinalhealth.com; scott.ballard#cardinalhealth.com
2) email addresses that it's being CC'd to, identified by "CC":
GMB-OptiFreight-CCBABR#cardinalhealth.com
3) email addresses that it's being CC'd to, identified by "ReplyTo":
OptiFreightcustomercare#cardinalhealth.com
4) Include report: True
5) Render Format: Excel
6) Subject: 13 Week Volume File - LifePoint Health - Brentwood, TN
Result:
"<ParameterValues><ParameterValue><Name>TO</Name>
<Value>gregory.dettorre#cardinalhealth.com;
scott.ballard#cardinalhealth.com</Value></ParameterValue><ParameterValue>
<Name>CC</Name><Value>GMB-OptiFreight-CCBABR#cardinalhealth.com</Value>
</ParameterValue><ParameterValue><Name>ReplyTo</Name>
<Value>OptiFreightcustomercare#cardinalhealth.com</Value></ParameterValue>
<ParameterValue><Name>IncludeReport</Name><Value>True</Value>
</ParameterValue><ParameterValue><Name>RenderFormat</Name>
<Value>EXCEL</Value></ParameterValue><ParameterValue><Name>Subject</Name>
<Value>13 Week Volume File - LifePoint Health - Brentwood, TN</Value>
</ParameterValue><ParameterValue><Name>Comment</Name><Value>Please see the
attached 13 week volume file and let us know if you have any questions.
OptiFreightcustomercare#cardinalhealth.com</Value></ParameterValue><ParameterValue><Name>IncludeLink</Name><Value>False</Value></ParameterValue><ParameterValue><Name>Priority</Name><Value>NORMAL</Value></ParameterValue></ParameterValues>"
Here there is an answered question on splitting strings, using SUBSTRING and CHARINDEX in SSRS. You Get the indexes of 2 delimiters (e.g. "TO" and "CC"), and by applying SUBSTRING between these 2 delimiters you get the value that you wanted.
Also, the best practice would probably be splitting the data in the dataset (e.g. SQL query) itself, instead of doing so in the report itself.

SQL query to bring all results regardless of punctuation with JSF

So I have a database with articles in them and the user should be able to search for a keyword they input and the search should find any articles with that word in it.
So for example if someone were to search for the word Alzheimer's I would want it to return articles with the word spell in any way regardless of the apostrophe so;
Alzheimer's
Alzheimers
results should all be returned. At the minute it is search for the exact way the word is spell and wont bring results back if it has punctuation.
So what I have at the minute for the query is:
private static final String QUERY_FIND_BY_SEARCH_TEXT = "SELECT o FROM EmailArticle o where UPPER(o.headline) LIKE :headline OR UPPER(o.implication) LIKE :implication OR UPPER(o.summary) LIKE :summary";
And the user's input is called 'searchText' which comes from the input box.
public static List<EmailArticle> findAllEmailArticlesByHeadlineOrSummaryOrImplication(String searchText) {
Query query = entityManager().createQuery(QUERY_FIND_BY_SEARCH_TEXT, EmailArticle.class);
String searchTextUpperCase = "%" + searchText.toUpperCase() + "%";
query.setParameter("headline", searchTextUpperCase);
query.setParameter("implication", searchTextUpperCase);
query.setParameter("summary", searchTextUpperCase);
List<EmailArticle> emailArticles = query.getResultList();
return emailArticles;
}
So I would like to bring back all results for alzheimer's regardless of weather their is an apostrophe or not. I think I have given enough information but if you need more just say. Not really sure where to go with it or how to do it, is it possible to just replace/remove all punctuation or just apostrophes from a user search?
In my point of view, you should change your query,
you should add alter your table and add a FULLTEXT index to your columns (headline, implication, summary).
You should also use MATCH-AGAINST rather than using LIKE query and most important, read about SOUNDEX() syntax, very beautiful syntax.
All I can give you is a native query example:
SELECT o.* FROM email_article o WHERE MATCH(o.headline, o.implication, o.summary) AGAINST('your-text') OR SOUNDEX(o.headline) LIKE SOUNDEX('your-text') OR SOUNDEX(o.implication) LIKE SOUNDEX('your-text') OR SOUNDEX(o.summary) LIKE SOUNDEX('your-text') ;
Though it won't give you results like Google search but it works to some extent. Let me know what you think.

Solr : what is the syntax for "LIKE" on filters (fq)

In my SOLR, i have indexed the keys (converted to string because the array wasn't saving) of the group which have the permission to display the object.
<visibility>
6-15-8
</visibility>
'fq' => "current_status_i:".Ressource::STATUS_PUBLISHED ." + lang_t:".$culture. "+ visibility_s".$visibility
The problem is that if the input for visibility is 15 it'll output 0 result because it does not match 6-15-8.
So , *what is the syntax to mimic the "LIKE" * in order to have result if the input is 15, or 8....
Thanks
You need to use multi-valued fields in Solr - they allow you to store multiple values for the same field. Check this and this for more details. Alternately, you can change the field type to ensure that the field is tokenized on - so that each value gets indexed separately.
Let me know how exactly you create the index and post your schema.xml. I will then be able to give you some more details about adding multi-valued fields to your index.
There are two options
Range query: fq=visibility:[1 To 15]
OR conditions: fq=visibility:6 OR 15 OR 8, (If you know these are the only 3 valid values in your system)