Umbraco 8: Searching Multi Node Tree Picker Content
Hi,
I'm looking to filter blog posts by category in a project I'm building in Umbraco 8, but I'm not sure how to have examine search the categories (selected in the back office via a multi-node tree picker) when filtering posts?
Right now I have
Blog Posts
Blog Post
Category 1, Category 2 (MNTP "categories" field)
Categories
Category 1 (has a "name" field to be filtered)
Category 2 (has a "name" field to be filtered)
A record looks like this:
So I guess I need some way to search inside the "categories" field to find the category node name(s) I'm looking for?
I was thinking as a fallback I could pull the categories back and find the ones with the ID's I was interested in so I could string match on the categories field, but this seems a bit... hacky?!
Looks good, bit of advice though, the way you are storing your date in the index won't be sortable if you did want examine to sort on the date. Just so you are aware.
The post I linked to talks about this so if this is something you need to consider it's worth a read :-)
I'm using a similar approach to this for a multi-select list of categories on a blog entry.
The issue I've run into is that if there is a category of "something" and another category of "something else", when you search for a category name of "something" via Searcher.CreateQuery, you'll get blog entries that have either of those 2 categories. Have you come across that issue and solved it?
Umbraco 8: Searching Multi Node Tree Picker Content
Hi,
I'm looking to filter blog posts by category in a project I'm building in Umbraco 8, but I'm not sure how to have examine search the categories (selected in the back office via a multi-node tree picker) when filtering posts?
Right now I have
A record looks like this:
So I guess I need some way to search inside the "categories" field to find the category node name(s) I'm looking for?
I was thinking as a fallback I could pull the categories back and find the ones with the ID's I was interested in so I could string match on the categories field, but this seems a bit... hacky?!
Cheers,
Paul
Hi Paul,
Okay, so a bit off topic but this blog post shows how you can manipulate the data going into the Examine Index (bit of self plugging as I wrote it the other day) https://www.justnik.me/blog/indexing-sort-able-dates-in-umbraco-version-8
But, this should give you a base idea of manipulating the index to put friendly names into the index.
To help with this I use a function a bit like this:
This adds a field to the index with the alias of your multi-node tree picker property and "Cleaned" appended to the end.
Then when you are searching you can do a text search against this field for your category :-)
Hope that helps
Nik
Cheers Nik! Yeah that gave me enough to put something together.
The indexer I think I'll eventually put some more work into to create a separate index, but updating the external index works for now.
Here's roughly what I came up with (was nice that I could use the strongly typed model in U8):
Looks good, bit of advice though, the way you are storing your date in the index won't be sortable if you did want examine to sort on the date. Just so you are aware.
The post I linked to talks about this so if this is something you need to consider it's worth a read :-)
Thanks
Nik
Ahh cool, was having some range query issuses with DateTime as well - changing to ticks sorted it out.
Hey Nik,
I'm using a similar approach to this for a multi-select list of categories on a blog entry.
The issue I've run into is that if there is a category of "something" and another category of "something else", when you search for a category name of "something" via Searcher.CreateQuery, you'll get blog entries that have either of those 2 categories. Have you come across that issue and solved it?
Regards, Matt
is working on a reply...