Hello fellow examiners! In my team we are building a site which has its users, outside umbraco, and we need to create a index with these users, but how is this done ? It seems like Examine is build to umbraco, but can i be used outside umbraco content? Buttom line is that umbraco dosn't contain enough functionality on the users for us to have our users inside umbraco, so we got our own table in the database with our users, so i can't get umbraco to index these users.
Does anyone have any experience creating own index with Examine, or should i just go straight at it and lucene lucene directly ? I would like to use examine, so i later on could use multiIndex for searching across both content and users.
Thanks for the code Alex. I'll give it a look. Was it a umbraco project ? How come didn't you use a examine for indexing, or has I understood examine in the wrong way about indexing ? - At the top of my head i could imagine that i should use Lucene for indexing, and afterwards be able to use examine for searching in the index.
To create your own index using examine see https://github.com/Shandem/Examine/tree/master/Projects there is sample project to index a database table you can use that or use same method and provide the data to index however you like. You can then use examine multisearcher. The one thing to note is building custom index with examine you make use of simpledataindexer this will index all items it will not allow you to add / update / remove one item at a time. So for example if you are indexing a database table when you index you will index the whole table and your index is a snapshot of table. If stuff is added to table it will not end up in your index until you rebuild. So if data in table is not updated regularly then you can set up a scheduled to rebuild the index.
Hi! I knep that this is an old TV-redaktionen but if I need to update just one item in the index i.e. when something is changed - is there an alternative to the SimpleDataIndexer-approach?
However you will need some way to call that method on a change. So in umbraco the reindex or add to index is called after publish event. Here depending on what data you are indexing you will need to after insert / update / delete can single update method. So if the data is in a sql server db table maybe a trigger that uses some .net assembly call (messy but is doable)
great to hear.. And once agian thanks for the code, i'll go through and watch your approach!
Ismail,
I have seen that project, but what i am hearing you say is that i can't add fields to the index. For instance which group the user is a member of which is umbraco content, when using examine ?
I am confused i thought you had all your members in separate system and I am assuming the groups they belong to? Or do you have users in one place and the groups they belong to in umbraco?
I understand you are confused, - We got users in a table outside of umbraco. But they relate to content item inside umbraco. I want to be able search in users which are, for instance: related to the content items im related to, so i find users which are indirectly related to me.
a example : in umbraco be got some workgroups, where users can write and so on. Users are members of these groups. I want be able to find users and weight them on the relation i as a user relate to other users.
so as i see it, i need to create a index of the users, and attach the content ids into the respected columns. (id: 1023, workgroupIds: 1034,1234,1567, unitIds:1111,1543) then i find users which are connected to the same workgroups and units as i am, and for instance boost the user in the search if he is.
Ok, so if you look at the code link that is in a loop of db rows, so in that loop you can for the given user get his / her linked content and add that to the index as a field then its searchable.
Sorry for the late answer, i've been away in the easter :)
I'm having major problems adding fields to the nodes. The nodes gets created properly, but there are no data assigned to it, and can't figure out why this is.
foreach (var user in users) {
Dictionary<string, string> dic = new Dictionary<string, string>();
If you do not then they will not end up in the index, with custom indexes you have to ensure all fields are in the config file it is not like umbraco indexes where if you do not have fields it will add everything.
creating own index with examine
Hello fellow examiners!
In my team we are building a site which has its users, outside umbraco, and we need to create a index with these users, but how is this done ? It seems like Examine is build to umbraco, but can i be used outside umbraco content?
Buttom line is that umbraco dosn't contain enough functionality on the users for us to have our users inside umbraco, so we got our own table in the database with our users, so i can't get umbraco to index these users.
Does anyone have any experience creating own index with Examine, or should i just go straight at it and lucene lucene directly ?
I would like to use examine, so i later on could use multiIndex for searching across both content and users.
Can anyone point me in the right direction ? :)
Hi Nicolas,
Few Weeks ago we did the same functionality. You can do your custom index easily. Example of reading from index: http://stackoverflow.com/questions/20927236/proper-way-to-get-readers-writers-in-lucene-net
Our class for working with Lucene:
In application start we add all our data to the index.
Thanks, Alex
Thanks for the code Alex. I'll give it a look.
Was it a umbraco project ?
How come didn't you use a examine for indexing, or has I understood examine in the wrong way about indexing ? - At the top of my head i could imagine that i should use Lucene for indexing, and afterwards be able to use examine for searching in the index.
It was MVC project without Umbraco. Examine is just tool for using Lucene, so you can use it too. Question is what do you prefer )
Examine we used for Umbraco project, and it was not bad ) but little bit hard for first time.
Niclas,
To create your own index using examine see https://github.com/Shandem/Examine/tree/master/Projects there is sample project to index a database table you can use that or use same method and provide the data to index however you like. You can then use examine multisearcher. The one thing to note is building custom index with examine you make use of simpledataindexer this will index all items it will not allow you to add / update / remove one item at a time. So for example if you are indexing a database table when you index you will index the whole table and your index is a snapshot of table. If stuff is added to table it will not end up in your index until you rebuild. So if data in table is not updated regularly then you can set up a scheduled to rebuild the index.
Regards
Ismail
Hi! I knep that this is an old TV-redaktionen but if I need to update just one item in the index i.e. when something is changed - is there an alternative to the SimpleDataIndexer-approach?
Markus,
If the index is custom one then you can do https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/78745-custom-examinelucene-index-with-ability-to-insert-update-individual-entries
However you will need some way to call that method on a change. So in umbraco the reindex or add to index is called after publish event. Here depending on what data you are indexing you will need to after insert / update / delete can single update method. So if the data is in a sql server db table maybe a trigger that uses some .net assembly call (messy but is doable)
Regards
Ismail
Alex,
great to hear.. And once agian thanks for the code, i'll go through and watch your approach!
Ismail,
I have seen that project, but what i am hearing you say is that i can't add fields to the index. For instance which group the user is a member of which is umbraco content, when using examine ?
Alex,
I am confused i thought you had all your members in separate system and I am assuming the groups they belong to? Or do you have users in one place and the groups they belong to in umbraco?
Regards
Ismail
Ismail,
I understand you are confused, -
We got users in a table outside of umbraco. But they relate to content item inside umbraco.
I want to be able search in users which are, for instance: related to the content items im related to, so i find users which are indirectly related to me.
a example :
in umbraco be got some workgroups, where users can write and so on.
Users are members of these groups.
I want be able to find users and weight them on the relation i as a user relate to other users.
so as i see it, i need to create a index of the users, and attach the content ids into the respected columns. (id: 1023, workgroupIds: 1034,1234,1567, unitIds:1111,1543)
then i find users which are connected to the same workgroups and units as i am, and for instance boost the user in the search if he is.
Does this make sense ?
Niclas,
Ok, so if you look at the code link that is in a loop of db rows, so in that loop you can for the given user get his / her linked content and add that to the index as a field then its searchable.
Regards
Ismail
Ismail,
Sorry for the late answer, i've been away in the easter :)
I'm having major problems adding fields to the nodes. The nodes gets created properly, but there are no data assigned to it, and can't figure out why this is.
foreach (var user in users) {
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("skillId", string.Join(",", user.Skills));
dic.Add("unitId", user.UnitId.ToString());
dic.Add("firstName", user.FirstName);
dic.Add("lastName", user.LastName);
list.Add(ExamineXmlExtensions.ToExamineXml(dic, user.Id, "user"));
}
this.AddNodesToIndex((IEnumerable<XElement>)list, "users");
The index gets created with the id, but nothing from the dictionary gets added..
Anyone tried having this problem ?
- Niclas Schumacher
Niclas,
In the ExamineIndex.config file do you have entry with fields for that index? Here is settings for one my custom ones:
If you do not then they will not end up in the index, with custom indexes you have to ensure all fields are in the config file it is not like umbraco indexes where if you do not have fields it will add everything.
Regards
Ismail
Ismail,
That worked great!
Now i'll try to to create my own indexer, so i gain more control..
Thanks!
is working on a reply...