-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Combining two different elements into one index #69
Comments
I haven't tested this, but I think you could use With the new feature in 1.2.1 you can also just do your checks in the transformer and if you don't want to index them return an empty array. |
Okay, I'll give it a look and see if anything can come of it! |
I am a bit late to this. There was a way to map different elementTypes to the same index. You would just map to the same index name. It worked for me. I recently started upgrading to the new version and have noticed that the unintended feature actually does not work in v2. @riasvdv there is no way one could use the same index name, but use two different element types? Say one for categories and another for entries? |
You should be able to set I haven't tested any of this yet, but I don't see a reason why it couldn't work |
@riasvdv thank you for the reply. I saw your comment earlier on about using Do you have any resources you could share? Not resources to Craft, but how to write it inside of the index configuration? I am not familiar with the My understanding is I define the elementType and then the criteria is based off of that elementType. But if I wanted to do say a category and entry elementType, that is where I am confused. |
@riasvdv I just wanted to let you know that I tested using the |
Didn't realise you couldn't start a query from the base Element class, I'll reopen this, but I don't know if I'll be able to find a solution for this. |
As a (temporary) solution, Algolia does allow searching multipe indices at the same time: https://www.algolia.com/doc/api-reference/api-methods/multiple-queries/ |
@riasvdv Is there a good reason for validating the index names are unique? I have config for each section based on my criteria that I am passing over that configures the values going into the index. I don't really think the unique check needs to happen, and I can't think of any negative side effects if it were to be removed. |
If you think removing it will have no negative side effects, and you can add some tests that prove multiple index configurations do the expected things, I'd gladly accept a PR that implements this. |
It would be nice if you could use CraftCMS manually and pass in an array or something, rather then using elementType, criteria, etc. So something like
Or something? Obviously this would be a high/advanced user not the default, but this would allow us to basically do anything. |
Found myself in the same scenario after needing to implement a global search that included both I got around Scout's
@riasvdv maybe you could add a |
Are you able to provide a full example of how you patched and or what needs to be done? It looks like you copied some git diff in your messagfe. |
@besimhu a patch is produced by diffing. To replicate what I did:
{
"extra": {
"patches": {
"rias/craft-scout": {
"No Scout Indices Validation": "patches/Scout-Indices-No-Validation.patch"
}
}
}
}
|
@nikolowry thank you, it worked as you described and I was able to finally upgrade to the latest version. |
@riasvdv what type of tests would you need to convince you multiple elements on one index works as expected? I've been indexing two elements -- Entries and Or thoughts on adding a boolean config setting to allow users to index multiple elements on one index? You could explicitly state it's an unsupported/experimental feature and devs should use at their own risk. I'm advocating for this because full-site search is such a core functionality of most CMS's and Craft is refusing to implement, craftcms/cms#878. Using Scout with the patch above, along with https://github.com/trendyminds/algolia, was the only way I could pull off Craft's traditional pagination in Twig. |
I agree with @nikolowry ... I am relying on the instantsearch.js and that does not allow for combining multiple indecies. I have some content that falls under categories, and while they are categories, they do contain website content. So when I am wanting to do a website search, I need to include those as part of the website index. |
@timkelty thoughts? |
Reading through this, my inclination is to keep So for @onebrightlight it might look something like this:
It seems like this would fit people's use-cases, while maintaining the 1-1 relationship of ScoutIndex to Algolia index. |
I'm confused: is this already implemented or will this be implemented in the future? |
@martinhellwagner not yet implemented, but thinking it should be a quick addition. |
We're running into the same issue. A solution as described in #69 (comment) would be a very welcome feature! ❤️ |
I also would love this functionality. Any progress or update on it? |
@elivz No progress, but I'm really hoping to carve out some time for some long standing Scout issues in the coming week. Does what I outline here fit your use-case? #69 (comment) |
@timkelty Yes! I think being able to pass in an array of items in place of the ElementType/Criteria query rules would open up a lot of possibilities. Not just combining different element types, but potentially even indexing non-Element data from a raw SQL query or pulling from an external API or whatever (not sure if that would cause other complications & I currently have no need for it...just thinking). |
@jornwildenbeest Sadly no, other than in my thoughts. I started a new position, so been quite busy. |
@timkelty Thanks for the update! |
any chances this feature will be realized sometime soon? |
@janhenckens, any progress on this? if not, would you accept a PR that went with the |
@gregkohn I know lots of people are waiting for this, so it seems like a PR would be valuable, unless @janhenckens has already started something. |
@gregkohn Sure would! Feel free to submit it and/or hit me up on discord if there's anything you'd like to discuss ! |
Hello @timkelty @gregkohn @janhenckens Is there anyway that I can help move this issue forward at all? If it is a case of things getting in the way and time not being on your side could we all collaborate in finding a solution to this issue? Thanks, |
👋 For my part, I've moved companies and switched focuses, and unfortunately won't be able to assist in moving forward here. Good luck! |
@mdunbavan Finding time is certainly a problem for me in this case. Happy to chat or have a call about how we could tackle if you'd like to give it a go! (feel free to ping me on discord, same username) |
It would be really interesting to hear why this feature of multiple elements/types/categories being saved to one index was removed from this version? I get that we need validation rules but one of the key killer features of Scout v1.1 was the ability to do this because algolia js worked so well with it.
This is what checks the unique names which is fine. Can we do something like create a new function such as |
I am looking to have a global index across multiple element types (in my case combining entries and assets). So a solution like this would be very crucial since it seems like there is currently not a way to do it with this plugin. |
Also looking forward for this feature, I would also like to combine Craft entries and Craft Commerce Products into same index. Any change of getting this feature soon? |
Also really needing this feature. We have multiple sites that need a site-wide search that includes entries and Calendar events. An ETA for this feature would be ideal so we know if we need to move forward with an alternative solution. |
Hey @Stalex89 @simonkuran, there's an open PR for this (#267) that I need to have a look at. I'll probably release it as a beta first so we can test it with a bunch of people, since this could impact performance. Would you need this is Craft 4 or 5? Just so I have a reference where it would need to be merged first? |
@janhenckens Thanks for your attention on this. Craft 4 support would be ideal, but if the feature needs to be Craft 5+ that would be ok. |
Craft 5 is so new that it makes sense to release it for both, but then I'll see about making a beta release for 4 first. I'll report back here on the progress. |
@janhenckens Thank you for your response! Would be nice to have it still on Craft 4 |
Making good progress on this! I'd like to add some more tests to cover this feature, hoping to tag a beta by the end of the week. |
Okay folks, calling everyone interested in this feature to test it out! To install:
Docs for the new syntax can be found here https://github.com/studioespresso/craft-scout/tree/feature/multi-elementtypes?tab=readme-ov-file#-getelementscallable-queries Please create a new issue for anything you run into while testing 🙏 |
I'll give this another 2 weeks to be tested (we're on beta.2 now) before releasing this. To install the latest beta:
Docs for the new syntax can be found here https://github.com/studioespresso/craft-scout/tree/feature/multi-elementtypes?tab=readme-ov-file#-getelementscallable-queries Please create a new issue for anything you run into while testing 🙏 |
Hey folks, I wanted to let you all know that this feature is now available in the latest releases for Craft 4 and Craft 5. Documentation can be found here: https://studioespresso.github.io/craft-scout/multiple-element-types.html |
Odd question, but we have all of our sections in one large index, but our Solspace Calendar events are a different element type. Since I can't add to an index more than once apparently, what are my options, if any for merging
craft\elements\Entry
andSolspace\Calendar\Elements\Event
into one index?The text was updated successfully, but these errors were encountered: