How to search the input keyword with all the fields of a table - rest

Hi am developing my first grails application now i want to put search method in my application.. Is it possible to match the single entered keyword with all the fields of the table.Like when i use findById it will search only on id or if i use findByName it will search only on name or findByDescription find only on description..
Is it possible to use findall or findBy* to match with all the fields like id, name, description..

If you are using a RDBMS, you can issue a query on the following lines:
SELECT .... FROM .... WHERE name like '%value%' OR description like '%value%' OR id like '%value%'
But this is going to be very inefficient. You can instead use a full text search API lucene/ solr and index entire content as part of one field and issue queries on that.

Related

Is there a possible way to search the name of a lookup fields using the search.query using apex in salesforce?

I had a lookup field on my object and I want to search the name of the lookup using search.query in apex, how can I do this?. In my debug, I am returning nothing. Below is my sample code.
String query = 'FIND \'Sonny McNeil\' IN ALL FIELDS RETURNING ASPHPP__ASPayment_Source__c (Id, Name,ASPHPP__PPContact__r.Name), Contact';
System.debug('query '+query);
List<List<sObject>> searchRecords = Search.Query(query);
System.debug('searchRecords '+searchRecords);
return searchRecords.get(0);
I've found a solution to my problem, it's not possible to use SOQL to search such certain name of a lookup field, all I do is use a sample SQL and add some LIKE condition on my sql and query it to the database and return

How to set display value in SAPUI 5, SmartField Value Helper field.

Hi: I am looking at the standard SAPUI 5 Smart Field demo:
https://sapui5.hana.ondemand.com/#/sample/sap.ui.comp.sample.smartfield/preview
I would like a field with a value helper, such as Currency on this screen, which displays the field description inside the input box instead of the field id.
Example:
Change the Category field from combo into a value helper (popup)
Get the field to display the CategoryName - or from the related table the LTXT field instead of the ID.
HowTo
That is easy: delete the line
from the metadata.xml file.
??? I have tried many, many things.
I doubt that anyone will reply, because there is most probably no good answer.I do not find this good functionality.
I think that I will need to change my ID field values for popup (value helper) fields to Description (ID) . Description need not be unique (one can have two relations to the same company with different ID's.)
By doing this we also "fix" the problem with the search ODATA command which searches the ID field. Of course users will want to search the descriptions.
In general SAPUI's value helper is not great. It is normal practice to use numerical ID's and descriptive descriptions. The description should be displayed and searched and not the ID. I found their filter generator on the popup screen nice - it is not all doom.

Mysql to Sphinx query conversion

how can i write this query on sphinx select * from vehicle_details where make LIKE "%john%" OR id IN (1,2,3,4), can anyone help me? I've search a lot and i can't find the answer. please help
Well if you really want to use sphinx, could perhaps make id into a fake keyword, so can use it in the MATCH, eg
sql_query = SELECT id, CONCAT('id',id) as _id, make, description FROM ...
Now you have a id based keyword you can match on.
SELECT * FROM index WHERE MATCH('(#make *john*) | (#_id id1|id2|id3|id4)')
But do read up on sphinx keyword matching, as sphinx by default only matches whole words, you need to enable part word matching with wildcards, (eg with min_infix_len) so you can get close to a simple LIKE %..% match (which doesnt take into account words)
Actually pretty hard to do, becuase you mixing a string search (the LIKE which will be a MATCH) - with an attribute filter.
Would suggest two seperate queries, one to sphinx for the text filter. And the IN filter just do directly in database (mysql?). Merge the results in the application.

Is it possible to perform a Sphinx search on one string attribute?

sql_query=SELECT id,headline,summary,body,tags,issues,published_at
FROM sphinx_search
I am working on the search feature of my Web site and I am using Sphinx, Perl and Sphinx::Search. As long as I want to search in all the attributes and I don't restrict it to just one, everything goes well. However when the user searches for a specific tag, I can't just give the result of a fuzzy search, I want to use the power of Sphinx to search only on tags or issues, maybe sometimes the user wants to search on headline and issues.
How can I perform such a task?
You need to put it in Extended Match Mode
https://metacpan.org/module/JJSCHUTZ/Sphinx-Search-0.27.2/lib/Sphinx/Search.pm#SetMatchMode
Then you can use Extended Query syntax
http://sphinxsearch.com/docs/current.html#extended-syntax
Which includes the field search operator
#tags keyword1
(Be careful with sphinx, the word "attribute" has a specific meaning - values attached to the document, useful for sorting/grouping/filtering and returning with the resultset. Whereas I think you are talking about fields. All the columns from the sql_query you dont mark as an attribute, are a field - and full text searchable)

Writing a query with ORMLite

How can I write a query with ormlite instead of using .create or any other thing like that? Can you please show me how for this simple example :
SELECT name FROM client
EDIT since I can't answer myself :
I guess I had to search a little more , anyway I found how to do it with the QueryBuilder like this :
newDao.query(newDao.queryBuilder().where.eq("name",valueofname)
If someone knows how to write the full query that would be great , otherwise , I'll stick with this solution
How can I write a query with ormlite instead of using .create or any other thing like that?
Goodness, there are tons of documentation about how to do this on the ORMLite site. Here's the section on the query builder.
I'm not sure what you mean by "full query" but your example will work with some tweaks:
List<...> results = newDao.queryBuilder().where().eq("name",valueofname).query();
It does not make sense to just return the name since the Dao hierarchy is designed to return the specific Client object. If you just want the name the you can specify the name column only to return:
... clientDao.queryBuilder().selectColumns("name").where()...
That will return a list of Client objects with just the name field (and the id field if it exists) extracted from the database.
If you just want the name strings then you can use the RawResults feature.