Lucene Queries documentation needs more work:
_source does not seem to be supported for example.Reset and Rebuild. It's not clear what's the difference between these two. Need examples of using "Liquid" params {{ param }} and using conditions {% if param != null %}.
I think people need to know that they can use Liquid in their Lucene Queries and to understand the fact that a Lucene Query is a Liquid Template.
It's also not obvious how to perform count query. When you are doing paging e.g. for blog posts, you need total count of all posts.
Doing a count is not scalable so it's been intentionally not documented / recommended.
Lucene Queries count issue is fixed with #4554
Here is a basic Lucene query you can run from the admin:
{
"from": {{ from }},
"size": {{ size }},
"query": {
"terms": { "Content.ContentItem.FullText": ["{{ terms }}"] }
}
}
with parameters:
{ from: 0, size: 10, terms: "terms" }
See also #4825
Hi guys, I have two questions relates to the Lucene as there is no clear documentation relating to the query.
As my understanding, we don't use the build-in query syntax of the Lusence. We borrow the DSL query syntax from the elasticsearch. Is that correct ?.
Is the current implementation of the query support all types of queries from the Elastic Search DSL ?.
I tried to do a simple query that follow this documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
However, It doesn't work. I received an error Invalid query: Invalid property 'filter' in boolean query.
Here is my query:
{
"query": {
"bool": {
"filter": {
"term": {
"Content.ContentItem.Published": "true"
}
}
}
}
}

I wonder if the current implementation support all query syntax. If It doesn't, is there any documentation tell us about the supported query ? or is there any workaround ?.
Did you try using true instead of "true"? I haven't used the Lucene Query for a long time unfortunately. Nowadays I much prefer the database content index. It is far more predictable to use.
thanks @dodyg, unfortunately changing it to true didn't help. I got the same error tho.
{
"query": {
"bool": {
"filter": {
"term": {
"Content.ContentItem.Published": true
}
}
}
}
}
This bellow simple query did work, that mean It only work with limited query template?. I don't know, but I don't want to risk myself with an approach with the un-controllable approach 馃槥
{
"query": {
"term": {
"Content.ContentItem.Published": "true"
},
}
}
any thought on this @Skrypt ?
@dodyg good idea about the DB index, is there any guide on this ?. I want to be able to index multiple Content-Type in the same query. It must support Full-Text Search as well.
If you want full-text search then I advise you staying with Lucene. Though indexing also is a good idea for quicker SQL transactions. These are 2 different things.
Here, if the issue is that the Lucene Query "filter" is not working properly, then we need to fix it.
But finding specific Content Items of multiple or single Content Types is easily achievable with the ElasticSearch / Lucene Queries. I will, when I have time, produce some Lucene Query examples for most common needs but it is really in the end a learning process of the ElasticSearch Query by looking at the documentation. Of course, some things are not yet working because the ElasticSearch Query language is based on top of the Lucene Java implementation which also has more functionalities than it's .NET Lucene implementation.
"Filter" here should surely work in OC. I'll try to take a look.
Ok, found where is the issue (I think).
CreateFilteredQuery() in BooleanQueryProvider class.
@hung-doan the DB Index is really useful for listing, etc but yeah for full text search, Lucene is the way to go.
These are the tables you can query https://docs.orchardcore.net/en/dev/docs/reference/modules/SQL/. It's all basic sql. Make sure the module is enabled.
Ok, found where is the issue (I think).
CreateFilteredQuery() in BooleanQueryProvider class.
@Skrypt @sebastienros do you want me to submit an issue to log it as a bug?.
I reported the issue here : https://github.com/OrchardCMS/OrchardCore/pull/2725
This should be fixed as part of that PR.
Most helpful comment
Ok, found where is the issue (I think).
CreateFilteredQuery() in BooleanQueryProvider class.