I have to convert property types from String to Long.
Now I want to search with XPath, QueryBuilder,... all properties "prop1" with type String to convert them into Long.
All queries I tried are giving only all nodes where "prop1" exists.
/jcr:root/content/dam/images//element(*,dam:Asset)[jcr:content/metadata/tiff:ImageLength]
Is there a possibility to do that? Because e.g. on http://docs.jboss.org/exojcr/1.12.13-GA/developer/en-US/html/ch-jcr-query-usecases.html I haven't found anything which helps me.
Greetings
Sören
The only function related to property types offered by the JCR queries is the CAST(), but it doesn't allow you to filter the results. Therefore, you can't find nodes with given property type using XPath, SQL or SQL2. Filter the results manually, using JCR API and the Property#getType() method.
Related
I'm starting with ElasticSearch.NET (trying Nest first).
A very basic question: all the search API methods I see (search, get, etc) require specifying a .NET type.
Isn't there a way to specify an index name so the API infers the response type automatically ? In other words, is it mandatory to create POCO objects for all Indexes we intend to search ? (I understand from the documentation that ElasticSearch can infer a document type from an index by using the structure of the first document...)
Isn't there a way to specify an index name so the API infers the response type automatically ?
Not currently. We've previously discussed doing something like this based on index patterns, which would be useful to support covariant responses across multiple indices when types are completely removed in the future.
In other words, is it mandatory to create POCO objects for all Indexes we intend to search ?
No it's not mandatory. You can specify any type you desire for TDocument in IElasticClient.Search<TDocument> and the type will be used to
determine the type into which to deserialize each _source document
Provide strongly typed access to document fields through their mapping to POCO properties.
I have a use case which is a bit similar to the ES example of dynamic_template where I want certain strings to be analyzed and certain not.
My document fields don't have such a convention and the decision is made based on an external schema. So currently my flow is:
I grab the inputs document from the DB
I grab the approrpiate schema (same database, currently using logstash for import)
I adjust the name in the document accordingly (using logstash's ruby mutator):
if not analyzed I don't change the name
if analyzed I change it to ORIGINALNAME_analyzed
This will handle the analyzed/not_analyzed problem thanks to dynamic_template I set but now the user doesn't know which fields are analyzed so there's no easy way for him to write queries because he doesn't know what's the name of the field.
I wanted to use field name aliases but apparently ES doesn't support them. Are there any other mechanisms I'm missing I could use here like field rename after indexation or something else?
For example this ancient thread mentions that field.sub.name can be queried as just name but I'm guessing this has changed when they disallowed . in the name some time ago since I cannot get it to work?
Let the user only create queries with the original name. I believe you have some code that converts this user query to Elasticsearch query. When converting to Elasticsearch query, instead of using the field name provided by the user alone use both the field names ORIGINALNAME as well as ORIGINALNAME_analyzed. If you are using a match query, convert it to multi_match. If you are using a term query, convert it to a bool should query. I guess you get where I am going with this.
Elasticsearch won't mind if a field does not exists. This can be a problem if there is already a field with _analyzed appended in its original name. But with some tricks that can be fixed too.
If I have a object of class Car that has an nested object of class Engine where both classes have the field named "id" do I have to do anything special when I create the mapping? Or is it sufficient to add the type "nested" to the engine mapping.
Elasticsearch head GUI is showing unexpected rows, but the search seems to give the correct result so it would be good to know if I need to do anything else in the mapping if two or more objects have the same field name.
Seems like the structured query builder returns the engine document with the id that I search for when I select car.id from the dropdown.
There shouldn't be any problem, you can just use the dot notation to refer to the fields in the nested documents.
Also, if you have a single engine per car you don't need to declare the engine as nested in your mapping.
I'm trying to do the following: I want to create a set of candidates by querying each field separately and then adding the top k matches to this set. After I'm done with that, I need to run another query on this candidate set.
The way how I implemented it right now is using a QueryWrapperFilter with a BooleanQuery that matches the unique id field of each candidate document. However, this means I have to call IndexSearcher.doc().get("docId") for each candidate document before I can add it to my BooleanQuery, which is the major bottleneck. I'm only loading the docId field via MapFieldSelector("docId).
I wanted to create my own Filter class, but I can't use the internal Lucene doc ids directly, because they are specified per segment. Any thoughts on how to approach this?
Instead of reading the stored docId, index the field (it probably already is) and use the FieldCache to retrieve docIds much faster. Then instead of using the docIds in a BooleanQuery, try using a TermsFilter or FieldCacheTermsFilter. The latter documentation describes the performance trade-offs.
I have googled a lot and also searched in stackoverflow.com about how to sort search results based on a Field Value in Lucene 3.0.2, but not found any useful data. I'm getting the search results from the index, based on the user query but not able to sort the results based on field like id or date.
I have pasted my code here for searching lucene index- http://pastie.org/1033974.
Please help me to solve this problem. If you provide me some example code or links where i can find that will be better.
Thanks
The IndexSearcher class has a couple of search methods that takes a Sort Object that you have to use. A Sort object is basically a wrapper around one or more SortField objects which hold details on what field to sort on and how.
Note that a field must be indexed to be used for sorting.