How to pass query for multiple columns search query in sugar CRM get_relationships soap api?
I passed related_module_query as: "accounts.name like 'abc' OR accounts.phone_office like 'abc'
If I search either by name only or by phone only its working correct but if I merge both like above it is pulling all records.
I believe in the inner working this has a previous query and joins your query with an AND clause.
Have you tried using parenthesis like this?
"(accounts.name like 'abc' OR accounts.phone_office like 'abc')"
Hope it helps!
Related
I have managed to create a query to get datasets by tags. For reference I have the following query:
http://localhost/api/3/action/package_search?fq=tags:(my-first-tag%20AND%20my-second-tag)&rows=2
Now, I need to filter these results by the group also. I added a dataset to a group and can see the group as:
http://localhost/api/3/action/group_list
But how can I add the group to the previous query? I can't seem to find anything that works.
You can use the filter query (fq) to search using the group name. For e.g to search the datasets that are in the test group
https://demo.ckan.org/api/3/action/package_search?fq=groups:test-group
To include the two fq, we need to make the query like this:
http://localhost/api/3/action/package_search?fq=tags:(my-tag-1%20AND%20my-tag-2)+groups:my-group-1&rows=2
I'm trying to prepare some boolean query for SOLR engine to find some docs with specific locality field. Results that I get seems to be very weird. I cannot give exactly the same code I use because of security policy in my company but trying to simplify this query:
+(ddm/10973/locality_pl_PL:Gdańsk)
And this query return results as expected with Gdańsk city. But when I add some another condition like this:
+(+(ddm/10973/locality_pl_PL:Gdańsk)+(status:0))
In my results I get docs with city Gdańsk and Gdańsk-Wrzeszcz. Suddenly ":" seems to work as a 'like' not 'equals' as expected.
Does somebody know what could be the reason?
I would like my autocomplete results with django-haystack to be distinct. However, if multiple objects in my database have a certain value for an attribute on which I am autocompleting, the result appears multiple times.
I am using Haystack with solr as my backend. My query, as in the tutorial, looks like:
SearchQuerySet().autocomplete(content_auto=request.GET.get('q', ''))[:5]
I'm new to Haystack, and the documentation seems limited.
Any help would be greatly appreciated.
Thanks!
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.
i am wondering how can i select specific number of child objects instead of taking them all with include?
lets say i have object 'Group' and i need to select last ten students that joined the group.
When i use '.Include("Students"), EF includes all students. I was trying to use Take(10), but i am pretty new to EF and programming as well, so i couldn't figure it out.
Any suggestions?
UPDATED:
ok, i have Group object already retrieved from db like this:
Group group = db.Groups.FirstOrDefault(x=>x.GroupId == id)
I know that i can add Include("Students") statement, but that would bring ALL students, and their number could be quite big whether i need only freshest 10 students. Can i do something like this: var groupWithStudents = group.Students.OrderByDescending(//...).Take(10);?
The problem with this is that Take<> no longer appears in intellisense. Is this clear enough? Thanks for responses
I believe Take(10) would be correct.
var Students= (from c in Groups
orderby c.DateAdded descending
select c).Take(10);
My experience with Take though is that it generates some awful sql.
EDIT:
see if this blog post helps, it talks of conditional includes.
http://blogs.msdn.com/b/alexj/archive/2009/10/13/tip-37-how-to-do-a-conditional-include.aspx
Couldn't make Gratzy's suggestion with conditional include work... and found the solution here: http://msdn.microsoft.com/en-us/library/bb896249.aspx
Query would look like this:
group.Students.Attach(group.Students
.CreateSourceQuery()
.OrderByDescending(x=>x.JoinDate)
.Take(10));
This is exactly what i was looking for!
Thanks for all responses anyway!