how can i get blogpost for one blog? i have 3 blogs and i want to get post of any of them
{
"query": {
"term" : { "Content.ContentItem.ContentType" : "BlogPost" }
},
"sort": { "Content.ContentItem.CreatedUtc": { "order": "desc" } },
"size": 2
}
how i should set my condition? i can see any value related to blog code. maybe we need to access parent of the list in liquid.
i have 3 blogs and i want to get post of any of them
Please rephrase, I personally don't understand it
@sebastienros for example in blog receipt, i want to create 3 different blogs (news, events, ...) and after that, i will add some blog post for everyone.
i want to show 2 latest blog posts in the index page for any blog types . with this query, it gives me all blogpost and i can't separate by blog types like just events or news posts.
You can't do that with Lucene Queries. I tried with Aggregate Queries and so far I've not had any success with it. Though, for that matter you will need to do SQL Queries since you are trying to retrieve elements from 3 different content types. Something that could be done is to implement ElasticSearch DSL to allow building custom indexes eventually. Right now you best bet is to use a SQL Query and to cache it with Liquid or Razor.
@Skrypt it really necessary to access sub items. i think it will easily if the OC be possible to index the parent id for every item. then we can have search by parent id.
You can try to do :
{
"query": {
"terms" : { "Content.ContentItem.ContentType" : ["BlogType1", "BlogType2"] }
},
"sort": { "Content.ContentItem.CreatedUtc": { "order": "desc" } },
"size": 2
}
Though it could possibly return more results than requested. I need to try at least with 3 blogs content types that have the same fields and parts.
i think it doesn't work. because i need subitems of these "BlogType1", "BlogType2".
Which are all blog posts? What are the names that you used for these "blog posts" or "articles"? The standard one is named "BlogPost". So you would instead put ["BlogPost", "BlogPostType2"]. But if your Blogs all contains BlogPosts then you just need to filter on the BlogPost type with the term query filter and not the term(s) one and it should work. Ahh ! Sorry I get it now you need to filter by BlogType.
i have blogs named "news" and "events" , i create them by "blog" type . I need to get the latest blogposts.
I get it now you need to filter by BlogType.
yes that is. 馃憤 and no way to filter.
You should try GraphQL 馃槈
do you have help for graphql? i need to learn that :)
An example :
query MyQuery {
blog(where: {displayText_in: "Blog"}) {
createdUtc
modifiedUtc
publishedUtc
list {
contentItems {
createdUtc
modifiedUtc
publishedUtc
... on BlogPost {
createdUtc
modifiedUtc
displayText
markdownBody {
markdown
}
}
}
}
}
}
thank's, where i can find an example to use this query with liquid?
There is no Liquid helpers for this ; you query the API through javascript or with a custom controller action on your frontend I believe.
i know , i should develop angularjs. if you have help for calling API please inform me.
You can query GraphQL this way :
https://localhost:44300/api/graphql?query=
And you copy/paste your JSON schema that comes from GraphiQL at the end of that URL.
@sebastienros using Graphql is good, but it's better to have access to parent id in the liquid query.
@aghili371 it's doable with a SQL query as we already index the id of the container (the blog). It's in the ContainedPartIndex table. You could then do 3 queries, one for each container. You can even do it from Liquid by defining a parameterized SQL query that would take the blog name or id and return the latest blog posts.
Though we also need to add this index to the Lucene index.
Though we also need to add this index to the Lucene index.
thank you for feedback. It will be great to select by container id in a liquid query.