I created word constraint on element repository
<constraint name="repository">
<word>
<element ns="http://lmpublishlearning.com" name="repository"/>
</word>
</constraint>
we have some document in which element repository value is blank like
<lmp:repository/>
Now in our search application how I can pass above type to get blank value document with word constraint. I try below different case but not able to get result.
rs:q=repository:''&rs:pageLength=10&rs:start=1&rs:sort=relevance"
rs:q=repository:""&rs:pageLength=10&rs:start=1&rs:sort=relevance"
It might meet your requirements to write a custom constraint:
http://docs.marklogic.com/guide/search-dev/search-api#id_97085
that returns
a cts:element-word-query on a tagged value that's not empty
a cts:element-value-query on a tagged value that is empty
Hoping that helps,
Related
Using Jaspersoft Studio 6.4.
I am trying to create a java.util.Collection, with nested type java.lang.String.
I want to populate the collection with the values from my data query: iterate through the values of the Field $F{CostCenter} and add each value to my collection. (My query is a domain query).
I have tried
Creating a collection variable
Incrementing the variable by my CostCenter group
Adding the field value to my variable
<variable name="dls_CCArray" class="java.util.Collection" incrementType="Group" incrementGroup="CCGroup">
<variableExpression><![CDATA[$V{dls_CCArray}.add( $F{costCenterSet.costCenterConcatenated} )]]>
</variableExpression>
</variable>
But my variable is null, even though i know my query is returning cost centers.
Reason I need to do this: I have an optional input control. When i select no cost centers, i still need to pass the list of cost center values returned by the query to my next report through my hyperlink parameter.
Thanks in advance
You can use a second variable to add the value to the collection variable. Also, since the engine might evaluate variable expressions more than once, it would be safer to collect the values in a Set so that you don't end up with duplicate values.
Therefore you could have something like this:
<variable name="Values" class="java.util.Set" calculation="System">
<initialValueExpression>new java.util.HashSet()</initialValueExpression>
</variable>
<variable name="ValueAdd" class="java.lang.Boolean">
<variableExpression>$V{Values}.add($F{costCenterSet.costCenterConcatenated})</variableExpression>
</variable>
I have a constraint based on an XML path range index, that is returning facet values for different types of letter casing:
<facet name="myFacet" type="xs:string">
<facet-value name="test TEST" count="1"/>
<facet-value name="Test Test" count="3"/>
</facet>
I want my facet values to be case insensitive, to where the above I would have 4 results for "Test Test". Is there a way of easily setting this in the options, the below I have is not working:
<constraint name="myFacet">
<range type="xs:string" facet="true">
<path-index>/path/to/data</path-index>
<word>
<term-option>case-insensitive</term-option>
</word>
</range>
</constraint>
Without manually lowercasing each item in the field in the data itself, is there a way to achieve this with a search option I can pass into the constraint?
You have to create a string index that uses a collation which includes the case-insensitive flag. You then refer to that string index as usual, but with the extra collation.
I recommend looking at the Admin ui, open the path indexes page of your database, create one of type string, and look for the collation builder button. It should pop up a little wizard that helps you compose the collation you need.
HTH!
I have a database in MarkLogic server. The database has many collections. Some of these collections have a namespace and some have different namespace. What is the query to know the distinct namespaces? My goal is to build a search application that would allow users to use a search bar and have the documents returned from the most relevant collections. Since all the collections have different xml structure I also want to customize the display of the documents base on the collection and search.
However you question is not clear to me but if you want to get all unique namespace from your DB you may run:
fn:distinct-values(//namespace-uri())
and if you want to get all unique collection from DB (on collection lexion of the DB):
cts:collections()
and if you want to perform search on particular collection only:
in search:search use:
<additional-query>{cts:collection-query('collectionName')}</additional-query>
in cts:search use:
cts:collection-query(("reports", "analysis")))
One way to get the list of unique collections in a database is to use the App Services Search API. You can specify a collection constraint in the search options which will return the unique collections. The example below specifies a collection constraint without a prefix, then returns a list of the facet values with the number of documents counted for each collection.
(: insert test documents here :)
xquery version "1.0-ml";
for $i in 0 to 5
let $collection := "https://example.com/" || $i
for $j in 0 to $i
return xdmp:document-insert("/example-doc/" || $i || "-" || $j, <example/>, (), $collection);
(: Use search API to get collections as a facet :)
xquery version "1.0-ml";
import module namespace search =
"http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
(: build a collection constraint facet :)
let $options :=
<options xmlns="http://marklogic.com/appservices/search">
<constraint name="collections">
<collection prefix="" facet="true" />
</constraint>
</options>
(: return facets ordered by the number of documents in each collection :)
let $facets := search:search("", $options)/search:facet/search:facet-value
for $facet in $facets
order by $facet/#count descending
return (element collection {($facet/#name, $facet/#count)})
Returning:
<collection name="https://example.com/5" count="6"/>
<collection name="https://example.com/4" count="5"/>
<collection name="https://example.com/3" count="4"/>
<collection name="https://example.com/2" count="3"/>
<collection name="https://example.com/1" count="2"/>
<collection name="https://example.com/0" count="1"/>
What I have seen most typically with applications built on MarkLogic is that they either have a single search ui for all document types, or separate search ui for each document type. You can always to full-text search across any document type, and you can define and show facets regardless if they apply to all or only a subset of the documents. Collection name could be a facet for instance, but you could also have a facet called Keyword that only applies to two of the collections, and another facet called Company that applies to three other ones.
In short, think of what end users functionality you'd like to provide first, and think how to technically implement that as second step. I doubt knowing the namespaces truly matters to the search ui, and likely only matters on index level.
HTH!
In Marklogic, I have to do unfiltered search in order to return the results of the facets. But, this option returns inaccurate results that does not have Search highlight.
I used the searchable Expression in order to get the Path of the Search results, here is the options that I used:
<search-option>unfiltered</search-option>
<searchable-expression>
/Book//chapter
</searchable-expression>
<constraint name="chapter">
<word>
<element name="chapter"/>
</word>
</constraint>
<constraint name="Author">
<range type="xs:string" collation="http://marklogic.com/collation/codepoint">
<element name="author"/>
</range>
</constraint> </options>
Also, I tried to add element query constraint, but it affect the performance of the search query
This is the search query:
search:search("chapter:List of Scenes", $options);
(SO timed out) If you're getting no facets with filtered search, it's because the search didn't produce facets. An unfiltered search can produce facets on text that didn't match the search but was in the same document as a matching indexed term.
Unfiltered searches are not a drop-in replacement for Filtered searches. If the Filtered searches are too slow then you should analyze your queries and data to find where optimizations are appropriate. Often a compromise is used - optimize a few searches to be fast, then use the results of those to do a 2nd filtered search on a subset of the results as needed to fill in the detail. See https://docs.marklogic.com/guide/performance.
I have a few objects created on my database and I need to delete some of the repeating attributes related to them.
The query I'm trying to run is:
UPDATE gemp1_product objects REMOVE ingredients[1] WHERE (r_object_id = '08015abd8002cd68')
But all I get is the folloing error message:
Error querying databse.
[DM_QUERY_E_UPDATE_INDEX]error: "UPDATE: Unable to REMOVE tghe attribute ingredients at index 1."
[DM_OBJECT_W_DELETE_ATTR_POSITION_ERROR]warning: "attempt to delete
non-existent attribute 88"
Object 08015abd8002cd68 exists and I can see it on the database. Queries like SELECT and DELETE work fine but I do not want to delete the whole object.
There is no easy way to do this. The reason is that repeating attributes are ordered, to enable multiple repeating attributes to be synchronized for a given object.
Either
set the attribute value to be empty for the given position, and change your code to discard empty attributes, or
use multiple DQL statements to shuffle the order so that the last one becomes empty, or
change your data model, e.g. use a single attribute as a property bag with pre-defined delimiters.
Details (1)
UPDATE gemp1_product OBJECTS SET ingredients[1] = '' WHERE ...
Details (2)
For each index; first find the value of index+1:
SELECT ingredients
FROM gemp1_product
WHERE (i_position*-1)-1 = <index+1>
ENABLE (ROW_BASED)
Use the value in a new query:
UPDATE gemp1_product OBJECTS SET ingredients[1] = '<value_from_above>' WHERE ...
It should also be possible to do this by nesting DQL somehow, but it might not be worth the effort.
Something is either wrong with your query or with your repository. I think you are mistyping your attribute name or using wrong index in your UPDATE query.
If you google for DM_OBJECT_W_DELETE_ATTR_POSITION_ERROR you'll see on this link a bit more detailed explanation:
CAUSE: Program executed a DeleteAttr operation that specified an non-existent attribute position (either a negative number or a number larger than the number of attributes in the object).
From this you could guess that type isn't in consistent state, or that you are trying to remove too big index of your repeating attribute, etc. Did you checked your repository with Consistency checker Job and other similar Jobs?
As of for the removing of repeating property (sttribute) value with DQL query, this is unachievable with single query since you need to specify index position which you don't know at first. But writing a simple script or doing it manually if it's not big amount of values to delete is the way you want to go.