Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lucene query throws ArgumentException while having taxonomy field #16691

Closed
effapp opened this issue Sep 8, 2024 · 7 comments
Closed

Lucene query throws ArgumentException while having taxonomy field #16691

effapp opened this issue Sep 8, 2024 · 7 comments

Comments

@effapp
Copy link

effapp commented Sep 8, 2024

Describe the bug

Lucene query throwed the ArgumentException while having toxonomy field

OrchardCore throwed the ArgumentException: "Can not add property ArticleItemForPublic.Category.Inherited to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object" when it executed lucene query that include taxonomy field index.

Orchard Core version

1.8.4 and 1.8.3

image

@effapp effapp added the bug 🐛 label Sep 8, 2024
@hishamco
Copy link
Member

hishamco commented Sep 8, 2024

Please steps to reproduce

@MikeAlhayek
Copy link
Member

MikeAlhayek commented Sep 8, 2024

@effapp I am guessing you are using the latest preview. Correct?

Please share the Widget-ContentFeedByTaxonomy.cshtml code. and your parts.

I am guessing in your entity.Add("key", obj) instead of entity["key"] = obj which is causing the exception. I just want to be sure it is not OC code that is causing this issue.

@effapp
Copy link
Author

effapp commented Sep 9, 2024

Hi @MikeAlhayek ,

I am using release 1.8.4 of OC.

It can execute correctly while replacing from lucene index and query to ElasticSearch index and query.

A pieces of code as follows:

var queryParams = new Dictionary<string, object>() { { "size", fetchCount }, { "from", from } };
if (!string.IsNullOrEmpty(categoryId))
{
queryParams["CategoryId"] = categoryId; // the error is same while using queryParams.Add("CategoryId", categoryId);
}
string query = (string)Model.ContentItem.Content.ContentFeedByTaxonomy.Items.Value;
var items = await Orchard.ContentQueryAsync(query, queryParams);

@MikeAlhayek
Copy link
Member

@effapp

queryParams["CategoryId"] = categoryId;

There this isn't the line that is causing the exception. Are
You able to reproduce this using OC branch? I would start there so you can understand the cause of the issue.

Another thing to try, is to try upgrading to OC 2.0 preview and see if you encounter the same issue. In 2.0 Newtonsoft.Json was removed from OC and YesSql.

@effapp
Copy link
Author

effapp commented Sep 9, 2024

@effapp

queryParams["CategoryId"] = categoryId;

There this isn't the line that is causing the exception. Are You able to reproduce this using OC branch? I would start there so you can understand the cause of the issue.

Another thing to try, is to try upgrading to OC 2.0 preview and see if you encounter the same issue. In 2.0 Newtonsoft.Json was removed from OC and YesSql.

But there is not the issue in index and query of ElasticSearch, still using Newtonsoft.Json.

@effapp effapp changed the title OrchardCore throwed the ArgumentException: Can not add property ArticleItemForPublic.Category.Inherited to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object Lucene query throwed the ArgumentException while having toxonomy field Sep 21, 2024
@effapp
Copy link
Author

effapp commented Sep 21, 2024

The lucene query can execute correctly in admin UI but throw exception by calling code : "var items = await Orchard.ContentQueryAsync(query, queryParams);"

the code "var items = await Orchard.ContentQueryAsync(query, queryParams);" is correctly in elasticsearch query.

@Piedone Piedone changed the title Lucene query throwed the ArgumentException while having toxonomy field Lucene query throwed the ArgumentException while having taxonomy field Sep 24, 2024
@Piedone Piedone changed the title Lucene query throwed the ArgumentException while having taxonomy field Lucene query throws ArgumentException while having taxonomy field Sep 24, 2024
@effapp
Copy link
Author

effapp commented Oct 7, 2024

The cause of issue has been identified: deleting "filter:[]" from query scripts is normal.

@effapp effapp closed this as completed Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants