Solr find all ids that start with certain path - solr

Have a number of id's that look like this:
/content/myProject/path1
/content/myProject/path1/page1
/content/myProject/path2
Now, I want to find all the children of path1, so I do /content/myProject/path1/*.
The problem is that I receive also /content/myProject/path2. How do I make a correct query ?
Thanks,
Peter

Sounds like you are using generic text tokenizer definition. You may want to look at the PathHierarchyTokinizer instead. It's designed to split at the path prefixes. And then, you will not need to do the * at the end.

Related

Get each item in a collection with one query

I have a collection of slugs and want to get each corresponding page with one query.
Something like ...
Page::whereIn('slug', $slugs)->get();
... does only return the first page matching any slug in the collection.
Currently there is a loop, but that are dozens of queries I want to avoid.
Try using the whereRaw method and imploding your array into a string:
Page::whereRaw('slug IN ("' . $slugs->implode('","') . ')')->get();
As it turned out, whereIn was the right way. There was one minor mistake in my logic, and at the same time insufficient seeding data, that blowed everything up.
If someone does not know: whereRaw should be used with caution. To avoid SQL injection vulnerability, all user-submitted entries have to be passed as parameters.
Page::whereRaw('slug IN (?)', [$slug]);
Beware: Wrapping ? with quotes is a syntax error. The passed data will be single-quoted by default, at least on my machineā„¢.
select * from `pages` where `slug` in ('page');

Search for list of words in body using simple

Is it possible to specify a variable list of words to check if they exist in body using simple? Something similar to:
simple("${in.header.type} in 'gold,silver'")
But using "contains" to search in
${in.body} (Camel 2.32.2)
Contains works with only one string at a time. To search for a list of strings in the body you can implement a processor to do so.

Is it possible to pass a dynamic group value to tokenizer in camel?

I want to specify the grouping size dynamically.
Is something like this possible ?
split().tokenize("\n", ..value from header or property...)
how to specify this value ?
--Clarifying: my question reads like I intend to dynamically change it during the execution of the route.
This is not what I need,
I need just a way to pass in a configurable splitsize, that is calculated in a bean.
No that is not possible, the group is a fixed number.
However instead of using tokenize you can use a java method call and return an Expression where you can do something similar to what TokenizeLanguage#createExpression does but where you can set the group value with a dynamic value.

Can I put letters instead of some numbers as ticks in a ValueAxis?

this is my program:
Program before
and I want it to look like this:
Program after
is this possible to add letters at some specific points in the ValueAxis?
I'm afraid that your links are not working, you may get a better responce using Imager and adding some example code or a Short, Self Contained, Correct Example.
In the meantime is this what you are trying to do

Apply pagination using Sunburnt highlighted search

I am using Sunburnt Python Api for Solr Search. I am using highlighted search in Sunburnt it works fine.
I am using the following code:
search_record = solrconn.query(search_text).highlight("content").highlight("title")
records = search_record.execute().highlighting
Problem is it returns only 10 records. I know it can be change from solr-config.xml but issue is I want all records
I want to apply pagination using highlighted search of Sunburnt.
Given the SOLR-534 issue, which is still unresolved, you can't tell Solr to give you all results, but you can use a really high rows parameter depending on how many documents you expect to have in your index. I don't know anything about sunburnt but I believe something like this should work:
search_record = solrconn.query(search_text).paginate(rows=10000).highlight("content").highlight("title")
You just have to replace the rows value with something enough big depending on your index size.
The general approach to this is to use a paginator:
from django.core.paginator import Paginator
paginator = Paginator(si.query("black"), 30)
Once that's done, you can just paginate through everything:
for result in paginator.object_list:
print result

Resources