I'm trying to do a partial search using Hibernate Panache. I'm building a backend using Quarkus and Kotlin. Now when my frontend gives me a search string I'd like to return all partial results.
I have the following query:
repository.find("firstName LIKE '%?1%'", value)
Now I've tried a couple of variations of this, including one with the .list() method.
Does anyone know how I should handle this?
repository.list( "lower(firstName) LIKE ?1", value.toLowerCase() + "%" );
But if you need more complex full-text queries, I would suggest to have a look at Hibernate Search
Related
I am using odata v5.7.0 for webapi(vb.net).I need all the properties of object should be expanded without using $expand property on the query string.
Ex: http://localhost:26209/ProductList?$expand=customers/products
into
http://localhost:26209/ProductList
Not sure why you would want to do that and there might not be a clear cut way to achive it.Still if you want to get all the products for a customer you will have to go one at a time by using something like this.
http://localhost:26209/ProductList/customers('customer_id')/products
Else if you are using OData 2 there is an EntitySet for every association, so you an directly query the products EntitySet and use $filter instead. The URL will look similar to
http://localhost:26209/Products?$filter=CustomerId eq *
You can check $filter conventions here
I am trying to perform a query where I need to filter on a property before I perform a transform, but the return type of Where() is IQueryable which apparently does not have a TransformWith extension method. What gives? The documentation examples show exactly this being performed.
session.Query<LocalizedService, LocalizedServicesIndex>()
.Where(s => s.Culture == Thread.CurrentThread.CurrentCulture)
.TransformWith<LocalizedServiceTransformer, LocalizedService>()
.ToList();
The indexed documents are of Type Service, and LocalizedService is a projection Type that is stored in the index.
Anyone run into this?
The .Where(...) in your case is using the standard where in "System.Linq" namespace but in order to use .TransformWith<>() you need to use the .Where(...) extension in "Raven.Client.Linq" namespace.
Make sure you have:
using Raven.Client.Linq;
in your code.
Could anybody help me to understand what kind of work is going behind the scene, when LINQ is used for retrieving SharePoint objects. For example, I can use a code like this:
private IEnumerable<List> newLists;
var dt = new DateTime(2010, 3, 20);
var query = from list
in clientContext.Web.Lists
where list.Created > dt && list.Hidden == false
select list;
newLists = clientContext.LoadQuery(query);
clientContext.ExecuteQuery();
How does it work?
How does request look like?
From documentation I found:
When you use the CSOM, you can write LINQ queries against client-side
objects, such as lists and Webs, and then use the ClientContext class
to submit these queries to the server. It's important to understand
that when you take this approach, you are using LINQ to Objects to
query SharePoint objects, not LINQ to SharePoint. This means that your
LINQ expressions are not converted to CAML and you will not see the
performance benefits that are associated with CAML conversion.
So, I was little bit confused, because I thought, that LINQ expression is transformed to Caml request. I can't understand how does it work. How can I watch details of request while executing ExecuteQuery() method? Could you please recomend me any tools for watching requests?
SP uses CAML internally: SP runtime converts Linq to CAML and send it via Soap request, or REST statement (if you are using RESTful services): http://msdn.microsoft.com/en-us/library/ff798339.aspx (with examples);
See more here:
http://msdn.microsoft.com/en-us/library/ff798464.aspx
and this can be helpful: http://nikspatel.wordpress.com/2012/08/05/sharepoint-2010-data-querying-options-server-om-vs-client-om-vs-rest-vs-linq-vs-search-api/
I am a new to using Mongo DB and exploring the frameworks around for migrating from mysql to mongodb. So far from my findings I have been able to figure out SpringMongo as the best solution to my requirements.
The only problem is that instead of using a DSL based or abstract querying mechanism, I wished the framework allowed me to pass plain json string as arguments to the different methods exposed by the API(find, findOne) so that the query parameters can be written out to an external file (using a key to refer) and passed to the methods by reading and parsing at run time. But the framework should be capable of mapping the results to the domain objects.
Is there a way in spring-mongo to achieve this? Or is there any other frameworks on the same lines
You could use Spring Data to do that, just use the BasicQuery class instead of Query class. Your code will look like the following:
/* Any arbitrary string that could to parsed to DBObject */
Query q = new BasicQuery("{ filter : true }");
List<Entity> entities = this.template.find(q, Entity.class);
If you want more details:
http://static.springsource.org/spring-data/data-mongo/docs/current/reference/html/#mongo.query
http://static.springsource.org/spring-data/data-mongodb/docs/current/api/org/springframework/data/mongodb/core/query/BasicQuery.html
Well I got to find this one in the Spring data MongoOperations...
String jsonCommand = "{username: 'mickey'}";
MongoOperations mongoOps = //get mongooperations implemantation
mongoOps.executeCommand(jsonCommand)
It returns an instance of CommandResult that encapsulates the result.
Im trying to return a SimpleQuery list that queries a single table and uses IN.
I can get this to work using
return new List<Jobs>(
ActiveRecordMediator<Jobs>.FindAll(Expression.In("ServiceId", ids))
);
However this is really really really slow. So id like to do something like this
SimpleQuery<Job> query =
new SimpleQuery<Job>(#"from Job as j where ? in (j.ServiceId)", ids);
return new List<Job>(query.Execute());
However I cant get the SimpleQuery to work. I cant find any documentation covering this and was hoping someone out there would be able to help.
Thanks
Have a look at the NHibernate HQL documentation here.
I'm guessing from your code, that you're after a HQL query to return all jobs where the job.ServiceID in a list of ids.
Maybe something along the lines,
IQuery q = s.CreateQuery("from Job as j where j.ServiceId in (:serviceIds)");
q.SetParameterList("serviceIds", ids);
BTW, have you heard of the NHibernate Lambda Extensions project?
Below is an example of the IN query done using the the mentioned library. Might be something interesting to look at as an alternative to using HQL.
DetachedCriteria after =
DetachedCriteria.For<Person>()
.Add(SqlExpression.In<Person>(p => p.Name,
new string[] { "name1", "name2", "name3" }));