Convert xpath queries to Query Builder in aem - xpath

I am trying to convert XPath queries to predicates that I can use with the QueryBuilder. For example, I have an XPath as follows:
xpath = /jcr:root/content/voda//element(*, cq:PageContent)
[(jcr:contains(#jcr:title,'*') or jcr:contains(.,'*')) and (#cq:template='/apps/cc/templates/people') and (#role!='Other') and #cq:template!='/apps/cc/templates/internalredirect']
/(rep:excerpt(.))
I want to use QueryBuilder instead of XPath.
Also, please suggest some reference material that would help me in general to change other XPath queries to a QueryBuilder format.

Related

Elastic search multiple regex search within same column in single request?

Using java client for elastic search, I can able to use only one regex pattern search. For now, I'm using like this.
searchSourceBuilder.query(QueryBuilders.regexpQuery("name", "AB.*"));
But I need elastic search equivalent of
SELECT NAME FROM USERS WHERE NAME LIKE 'AB%' OR 'SID%'
I am using RestHighLevelClient. Is there any way to do multiple regex search within same column?
Thanks in advance.
You need to add both regexp queries inside a bool/should:
QueryBuilder first = QueryBuilders.regexpQuery("name", "AB.*");
QueryBuilder second = QueryBuilders.regexpQuery("name", "SID.*");
QueryBuilder boolQuery = QueryBuilders.boolQuery()
.should(first)
.should(second);
searchSourceBuilder.query(boolQuery);

Difference between BoolFilterBuilder VS boolquerybuilder vs FilteredQueryBuilder

I've been using boolquerybuilder. The results are fine.
Whats the purpose of using BoolFilterBuilder and FilteredQueryBuilder.
can i use them instead of boolquerybuilder?
Since version 2.0 Filtered Query is removed.
Use the bool query instead with a must clause for the query and a filter clause for the filter
see here
by

Xpath or Xquery with Eloquent

Is it possible to use Xpath or Xquery to query XML type fields in a database using Eloquent ORM ? I find in inconvenient to parse the XML every time and filter my results in memory. I would rather return my results from a query, is there a way to achieve that using Eloquent or I'm stuck with raw database statements?
Thank you
I reviewed the options for selecting items in Eloquent and there is not much good options to select based on XML values as you expect. You can use some wildcards and run calculations on Eloquent to filter needed data but none of these are very efficient.

Elasticsearch "Query string" query on Geo?

I'm trying to do a query on Elasticsearch using the query string interface on a Geolocation. Specifically, I am trying to return all documents within a circle (point with radius). This is clearly possible using the full query DSL based on JSON. However, I can't find the syntax for the same search using query strings in the docs here:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax
Does this mean geo queries are not supported by query string queries?
Thanks
No. It's not supported as far as I know.

xpath Max DateTime

I'm having a problem with xpath query. I have a schema with two DateTime fields and I need the Max Datetime from all the records in the schema.
this is my Xpath:
xPath_a = "max(/libary/DateTime1)";
any suggestion about how to make it work in Xpath?
Unfortunately, the version of XPath and Xslt supported in .Net still 1.0 so that's what BizTalk uses.
XPath 1.0 does not have a max() function.
Since the syntax you posted suggests an Orchestration, the most practical option is a helper class that takes message as a XmlDocument parameter.
This thread has an example of hot to use an XPathDocument and an XmlDocument: http://social.msdn.microsoft.com/Forums/en-US/e6addfe7-c94f-495b-9e79-35c48844b33f/select-max-value-from-xml-file?forum=xmlandnetfx
This thread provides examples of using XDocument and LINQ: Get max attribute value from XML using LINQ

Resources