element-query | JS Polyfill for element queries | Media library
kandi X-RAY | element-query Summary
kandi X-RAY | element-query Summary
Element query is a little JS library designed to enable CSS "element queries," or queries nested inside CSS selectors. While traditional media queries always relate to the viewport or window, element queries relate to the state of particular elements on the page. This allows for modular media queries. Just include the element-query.js script on your page and you can start using some basic element queries right away.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of element-query
element-query Key Features
element-query Examples and Code Snippets
Community Discussions
Trending Discussions on element-query
QUESTION
I am trying to understand difference between cts:element-query
, cts:element-value-query
and cts:element-word-query
using cts:search()
.
When someone can achieve the same thing using all three why did they created these many?
I am sure I am missing something here to understand. I have following data:
...ANSWER
Answered 2021-Jan-11 at 13:32Those three cts:element-* query functions have some overlapping functionality, and it is possible to get the same results, but there are some key differences that affect what is possible and how efficient the query may be for your system.
cts:element-query()
is a container query. It matches the element specified in the first parameter. The query from second parameter is applied to the matched element and all of its descendants. So thects:word-query
would match the text of COUNTRY or any descendant elements, if there were a more complex structure.Using
xdmp:plan()
to see the query plan,
QUESTION
I have a MarkLogic query written in XQuery and I would like to convert it to Java API using StructuredQueryBuilder
. Unfortunately, I can't find Java equivalent for cts:element-query
. Can you please show me how to implement it in Java?
The query that I want to convert:
...ANSWER
Answered 2020-Jun-18 at 17:21The StructuredQueryBuilder.containerQuery()
method constructs a search:container-query
in the Search API. On the enode, the REST API converts the search:container-query
to cts:element-query()
or cts:json-property-query()
or cts:json-property-scope-query()
as appropriate.
For more detail, see:
http://docs.marklogic.com/guide/search-dev/structured-query#id_87231
The other way to provide the query in the Java API is to serialize the cts:element-query()
as JSON or XML to learn the query structure and then use a DOM to construct the query and pass the query as a RawCtsQueryDefinition
payload.
For that approach, see:
http://docs.marklogic.com/guide/java/searches#id_45762
http://docs.marklogic.com/javadoc/client/com/marklogic/client/query/RawCtsQueryDefinition.html
Hoping that helps,
QUESTION
We are developing an enterprise application which store huge amount of data. In our application we forced the user to create multiple Path Range Indexes to make search faster.
Earlier we were taking advantage of Path Range Indexes to make search faster using cts:path-range-query() but now I found that same result I can get using cts:element-query() without creating Path Range Indexes.
For Example -
Using cts:path-range-query() -> Here I need to create Path Range Index for /tXML/Message/INVENTORY/ASNId
xquery version "1.0-ml"; cts:uris('', (), cts:and-query((cts:collection-query("integration"), cts:path-range-query("/tXML/Message/INVENTORY/ASNId", "=", "10121600"))))
Using cts:element-query() -> Here I dont need Create Path Range Index.
xquery version "1.0-ml"; cts:uris('', (), cts:and-query((cts:collection-query("integration"), cts:element-query(xs:QName("tXML"),cts:element-query(xs:QName("Message"), cts:element-query(xs:QName("INVENTORY"), cts:element-value-query(xs:QName("ASNId"), "10121600")))))))
My questions are,
If I am getting the same result as cts:path-range-query() using cts:element-query() then why do I need to force the user to create Path Range Indexes ?.
which query is suitable for huge set of data ?.(cts:element-query() or cts:path-range-query())
Please help me to find answers of these two questions.
...ANSWER
Answered 2020-Feb-03 at 11:23The answer is not entirely straight-forward, meaning that results might vary depending on data, and volume.
A couple of notes though:
- Your queries are not semantically the same. Element-queries check for ancestors, while in a path you can be more strict, and require specific parents, so direct parent-child rather than ancestor-descendant relations
- Range queries are resolved against range indexes with predefined collations, and always against entire ('exact') value. Value queries are resolved against universal index however. More specifically, against the index with unstemmed tokens. If your value consists of multiple tokens, it would require positions to be enabled, or filtered searches for accuracy. The value in your example consists of only one token though.
- Path range indexes come at a cost at ingest time, slightly bigger than element range indexes. Range indexes also take extra memory. Element queries, and element value queries take slightly more work to resolve at search time. Though, you might need a big test set to notice significant differences.
- Last but not least, you can't do inequality queries, or value lookups for facets and such without range indexes.
HTH!
QUESTION
What i want to do is similar in the following link but we want it using search:search
:
Basically we have 2 xmls like the following:
XML-1 ...ANSWER
Answered 2019-Jun-03 at 14:44You are on the right track. Use the container
option, which works like any other constraint option, then wrap your nested query in parenthesis.
For example:
QUESTION
After playing with MarkLogic I realized results from triples can be obtained in several ways for example by fully using either Xquery or SPARQL. So the question is that, are there any advantages using SPARQL over XQuery? Is there some indexing going on which makes SPARQL much faster then searching for a certain semantic query?
For instance if we are retrieving all semantic documents with the predicate "/like".
SPARQL
...ANSWER
Answered 2019-Mar-11 at 08:18Yes, there are definitely differences. Whether XQuery or SPARQL is most efficient however fully depends on the problem you are trying to solve. XQuery is best at querying and processing document data, while SPARQL really allows you to reason easily over RDF data.
It is true that RDF data is serialized as XML in MarkLogic, and you can full-text search it, and even put range indexes on it if you like, but RDF data is already indexed in the triple index, which would give you more accurate results than the full-text search of above.
Also note that SPARQL allows you to follow predicate paths, which involves a lot of joining. That will be much more efficient if done via SPARQL than via XQuery, because it is mostly resolved via the triple index. Image a SPARQL query like this one:
QUESTION
I'm trying to understand the impact of the element word positions
index setting.
See the following xquery which returns the plan of a simple element-word-query
search:
ANSWER
Answered 2018-Dec-28 at 15:31When you turn on positions, we store a positions vector for each document in the index for the relevant term, instead of just the document id.
The way to think about this is in terms of the specificity of the leaf queries and the work involved in calculating them and intersecting intermediate results.
When you see a term-query in the query plan, that means it is just looking up document ids, so there is no knowledge of relative positioning -- a less accurate result for a long phrase like this, because the "element word" and "word position" could be occurring in two separate parent elements in the document. If your data only ever has one element with this name in each document, that could not happen, although you could still have false matches where the two-word subphrases occur in, say, the reverse order, or separated by other words.
When you see word-query in the query plan, that means we are going to be looking at positions, and here you see the relative positions for each of the words in the phrase. When this is resolved, we examine the positions vector and toss out the ones that don't mean this positional constraint. So all the matches will have this sequence of words in this order: a more precise match.
The element-query in the plan is also applying positional constraints, of the element instances relative to the matches inside the element. There are optimizations where the element positional constraints are actually pushed down to the leaves of the query tree to avoid excess intermediate calculations.
You also see some technically redundant term queries: the point of these is to do simple term lookups that are probably more constrained than the leaf word queries. Since intersection of term lists from an and-query always proceeds from the shortest matching posting list, this can provide a fail-fast mechanism to avoid the more expensive positions calculations. There is a certain amount of heuristic judgement in that, and given a complex set of index options and query variations, sometimes those additional terms are, in fact, not helpful.
QUESTION
When I turned on punctuation-insensitive
in my cts:word-query
, even then the NEAR
query is breaking the -
word into two words
ANSWER
Answered 2018-Jul-27 at 01:44This actually has nothing do with punctuation in resolving your search but rather how MarkLogic tokenizes and indexes the position of individual words. By default, MarkLogic's tokenization breaks hyphenated phrases into separate words. You can use a custom tokenizer to dictate how MarkLogic should index words if you don't like the default behavior. There is a pretty detailed guide on using a custom tokenizer to ignore hyphens in word tokenization available here.
For your case, I'm not sure I would recommend you explore using a custom tokenizer. There can be unintended consequences and it's not as performant as using the default tokenization. Instead, it would probably make more sense to adapt your code to how the default tokenization works.
Let's look at : comparative, interventional, quasi-experimental study
It would be tokenized like :
QUESTION
I am looking for given string, it has to be in *(*)
format, *
should not have space, no two words before (
.
I am searching MarkLogic DB to see if given column value is in [^\s]+\((?!\s)[^()]+(? format, if not replace it with this format.
I am still stuck at fetching data, and could not write the query to update
I am searching DB as
...
ANSWER
Answered 2018-May-18 at 06:44The fn:matches
function does not support group modifiers like (?!
and (?. Simplify your pattern, and capture false positives after the match with another match if necessary.
Doing an educated guess at what you are trying to do, I think you are looking for something like:
QUESTION
I have a strange issue with near query..
...ANSWER
Answered 2018-Jul-13 at 15:38I believe MarkLogic indexes word distances starting with the anchor word at a location of 0, and the subsequent token at a distance of 1 etc. In order query neighboring words you need to use a near-query distance of 1. The queries in your examples are performing correctly.
To borrow from the MarkLogic cts:near-query documentation:
QUESTION
I have a question regarding the behavior of the wildcarded search in MarkLogic.
Basically, what I am trying to do is to replicate the SQL like %something% query.
Here is the code that returns false positives:
...ANSWER
Answered 2018-Jul-06 at 21:02Unfiltered wildcard queries within specific elements (i.e. not just with a document) may return false positives without positional indexes. I would try enabling either or both of word positions
and element word positions
. It may also be worth testing whether you see additional performance improvements from enabling fast element phrase searches
.
It's possible that simply because "*something and something*" contains more terms it is filtering out false positives and not because it is more accurately resolving that phrase though indexes.
Update: After reviewing your updated test case, it appears that trailing wildcard index accuracy is not good enough without trailing wildcard word positions
enabled. That and three character word positions
appear to be necessary to resolve this type of leading-and-trailing element wildcard query.
I would recommend disabling one character searches
and two character searches
if they are not strictly necessary, since they will generate large indexes. fast element character searches
and fast element trailing wildcard searches
also do not appear to be required for accuracy in your case, so you might want to test if your queries are fast enough without them.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install element-query
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page