ExternalIndex index unpublished nodes

Hi,

Im using ExternalIndex to fetch all my nodes. And it works all great now, but i can’t seem to propperly also index unpublished nodes aswell.

if (!_examineManager.TryGetIndex("ExternalIndex", out var index)) return NotFound();

var searcher = index.Searcher;
var query = searcher.CreateQuery("content").NodeTypeAlias("eventPage");

var totalSearchResults = query.Execute(QueryOptions.SkipTake(0, 9999));

in /umbraco/#/settings?dashboard=settingsExamine
all i can see is PublishedValuesOnly = true, but i want it to be false. But can’t find the right way to do it.

I’ve been trying many things, but without luck…

BR
Mike

The external index is meant for published content, not for unpublished content. Also, if you put unpublished content in the published index, you might expose unpublished data. I suggest you use the internal index if you want all data.

But let’s take a step back, what do you want to accomplish?

Hi @LuukPeters

Well makes sense, i was only jsut getting into querying the nodes by this way.
So if i were to use Internal instead i should edit would it be enough to change the index, like this?

if (!_examineManager.TryGetIndex("InternalIndex", out var index)) return NotFound();

What i want to do.
I have a case where i want to render out the current pages that belongs to a user.
That works all fine with the give code in the post before. But the user also have an option, where the can “Save and publish” later. So when they do that, i unpublish the page and just “Save” it, not publish. So in the ExternalIndex, they are just gone from the page after that. not being counted in as the result.

Hope that makes sense.

Yeah I’d definitly look into the internal index in your case. And if you are missing some data, you could always extend the existing indexes

I see you labeled you post with Umbraco v11. You do know that that version is no longer supported, right?

@LuukPeters Thanks i will take a look! :flexed_biceps:

Yes, thats correct. We are gonna update it soon also.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.