Umbraco - Examine index not updated - search

I am using Umbraco CMS, and trying to use its site search function that uses Examine.
When I edit a page and publish it, the examine index is not updated, hence search results are always out of date. I have to manually delete the Index folder to update it.
Shouldn't the index be updated automatically everytime you update the content?

I wrote a class that updates the index on publish.
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.web;
using Examine;
public class UmbracoEvents: ApplicationBase
{
/// <summary>Constructor</summary>
public UmbracoEvents()
{
Document.AfterPublish += new Document.PublishEventHandler(Document_AfterPublish);
}
private void Document_AfterPublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
{
// Rebuild SiteSearchIndexer
ExamineManager.Instance.IndexProviderCollection["SiteSearchIndexer"].RebuildIndex(); // Unfortunately this doesn't index the latest change, must republish to index it
}
}
However it doesn't get the latest change even if it is supposed to run "after" publish. So, to make the search results up to date, you have to publish twice :S

You can manually update the index by using Examine Dashboard.
To automatically rebuild indexes on app startup, you could add this line into ExamineIndex.config located in config directory
<Examine RebuildOnAppStart="true">
Indexes should rebuild automatically when you publish/republish a content node. If it doesn't work, you may have configuration problem with Examine.

Related

CRAFTER: Is it possible to change the value of a specific attribute of a specific component?

I was wondering if there is a solution to only change the value of an attribute in a specific component using the Crafter Studio API or a groovy script.
The only thing I have found is the method "Write Content"(https://docs.craftercms.org/en/3.0/developers/projects/studio/api/content/write-content.html) of the API but to only change one attribute you need to retrieve the entire component file, modify the value you need and push the entire file back, that is quite heavy.
Write content API is the only API that writes content at the moment.
If you're working on the UI, you could use our #craftercms/studio-ui package to write single fields easily as this is abstracted for you there.
yarn|npm install #craftercms/studio-ui
import { updateField } from '#craftercms/studio-ui/services/content'
updateField(
'yourSiteId',
'/path/of/the/xml/or/objectId/if/embedded.xml',
'idOfTheField_s',
indexOfItem, // If it is a collection (node-selector, or repeat group), send null otherwise,
parentModelId, // null unless you're working with embedded content
newValueOfTheField
).subscribe(() => {
console.log('Field update complete');
});

Restore Fixed Assets records with custom field and related table records

In Fixed Assets (FA303000), I have customization that contains two custom fields and one custom table which is a child table referenced with FixedAsset's AssetID column.
Now, for some reason, we have to delete half of our fixed assets and put it back into Acumatica again. We are not creating the whole snapshot to create and restore the process. We are processing half of fixed assets records by removing it and put it back.
My initial thought was I just needed to put those records into some temporary table using (select * into duplicate_FixedAsset from FixedAsset.) then, delete those records from FixedAsset and put it back into FixedAsset.
Custom Fields record from Fixed Assets will be back, and for my custom child table that is linked via AssetID, I can use AssetCD to get AssetID and link it back again and everything should be fine.
But, I got wrong when inserting this record didn't appear back into the Fixed Assets page.
Upon inspecting Row_Deleting event, I found below code snippet.
protected virtual void FixedAsset_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
{
FixedAsset asset = (FixedAsset)e.Row;
if (asset == null) return;
if (null != (FATran)PXSelect<FATran, Where<FATran.assetID, Equal<Current<FixedAsset.assetID>>, And<FATran.batchNbr, IsNotNull>>>.SelectSingleBound(this, new object[] { asset }))
{
throw new PXSetPropertyException(Messages.BalanceRecordCannotBeDeleted);
}
this.EnsureCachePersistence(typeof(FARegister));
this.EnsureCachePersistence(typeof(FABookHistory));
foreach (FARegister reg in PXSelectJoinGroupBy<FARegister,
LeftJoin<FATran, On<FARegister.refNbr, Equal<FATran.refNbr>>>,
Where<FATran.assetID, Equal<Required<FixedAsset.assetID>>>,
Aggregate<GroupBy<FARegister.refNbr>>>.Select(this, asset.AssetID))
{
this.Caches<FARegister>().Delete(reg);
}
foreach (FABookHistory hist in PXSelect<FABookHistory, Where<FABookHistory.assetID, Equal<Required<FixedAsset.assetID>>>>.Select(this, asset.AssetID))
{
this.Caches<FABookHistory>().Delete(hist);
}
}
So, it doesn't seem that simple process that I have thought at the beginning. It shows that FARegister and FABookHistory are linked as well.
So, I would really appreciate it if I know what is the proper steps to follow to make sure that not only I get the Fixed Assets back without breaking any relation to other tables but also properly link back to my custom fields and table.

Maximo: can i filter the list on multiple criteria of Status field

when i list the inventory, the default setting filters the Status field with "!=OBSOLETE".
Can I put in a command that will not list any items with status of obsolete or pendobs.
or filter the list on 2 different status'
You can filter the list to two different statuses. For that you put something like (without the quotes) "=status1, =status2".
That same trick never worked for me to filter out more than one status. "!=status1, !=status2", for example, would not work.
Saved and default queries can help take care of that if you wish.
If you have access to the Where Clause, you could edit there query to state something like this:
status not in ('obsolete', 'pendobs')
This is the best way I've found to do an exclusive query as opposed to the standard inclusive query.
Out of the box, you can add PENDOBS to the filter so you exclude OBSOLETE and PENDOBS. If you want the behavior of the application to change, you have to edit the Java .class file in this case. Some modules allow you to edit this from Application Designer, but it is strange that Inventory module, requires editing the .class file.
c:\IBM\SMP\maximo\applications\maximo\maximouiweb\webmodule\WEB-INF\classes\psdi\webclient\beans\item\ItemAppBean.class
Below is the relevant Java code. You'd have to edit the Java file and rebuild your maximo.ear for the List view to exclude PENDOBS from the list view.
public void initializeApp()
throws MXException, RemoteException
{
DataBean resultsBean = app.getResultsBean();
Translate translate = MXServer.getMXServer().getMaximoDD().getTranslator();
String status = (new StringBuilder()).append("!=").append(translate.toExternalDefaultValue("ITEMSTATUS", "OBSOLETE", null, null)).toString();
resultsBean.setQbe("status", status);
resultsBean.reset();
super.initializeApp();
}

What to do when get "The model used to open the store is incompatible with the one used to create the store"?

I had a core data EntityDescription and I created data in it. Then, I changed the EntityDescription, added new one, deleted the old one using the editor for xcdatamodeld file.
Now any of my code for core data causes this error "The model used to open the store is incompatible with the one used to create the store}". The detail is below. What should I do? I prefer to remove everything in the data model and restart new one.
Thanks for any suggestion!
reason=The model used to open the store is incompatible with the one used to create the store}, {
metadata = {
NSPersistenceFrameworkVersion = 320;
NSStoreModelVersionHashes = {
Promotion = <472663da d6da8cb6 ed22de03 eca7d7f4 9f692d88 a0f273b7 8db38989 0d34ba35>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
);
NSStoreType = SQLite;
NSStoreUUID = "9D6F4C7E-53E2-476A-9829-5024691CED03";
"_NSAutoVacuumLevel" = 2;
};
Or if you're in dev mode, you can also just delete the app and run it again.
Deleting the app is sometimes not the case! Suggest, your app has already been published! You can't just add new entity to the data base and go ahead - you need to perform migration!
For those who doesn't want to dig into documentation and is searching for a quick fix:
Open your .xcdatamodeld file
click on Editor
select Add model version...
Add a new version of your model (the new group of datamodels added)
select the main file, open file inspector (right-hand panel) and under Versioned core data model select your new version of data model for current data model
THAT'S NOT ALL ) You should perform so called "light migration".
Go to your AppDelegate and find where the persistentStoreCoordinator is being created
Find this line if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
Replace nil options with #{NSMigratePersistentStoresAutomaticallyOption:#YES, NSInferMappingModelAutomaticallyOption:#YES} (actually provided in the commented code in that method)
Here you go, have fun!
P.S. This only applies for lightweight migration. For your migration to qualify as a lightweight migration, your changes must be confined to this narrow band:
Add or remove a property (attribute or relationship).
Make a nonoptional property optional.
Make an optional attribute nonoptional, as long as you provide a default value.
Add or remove an entity.
Rename a property.
Rename an entity.
Answer borrowed from Stas
If this is a non-production app, just delete your local database (appname.sqlite) and restart the app.
I find I'm always doing this, and so provide the following additional detail:
Under XCode 4 (4.3.2) you should find your datastore here:
/Users/~/Library/Application Support/iPhone Simulator/simulatorVersion/Applications/yourAppIdentifier/Documents
Or you can use Spotlight, if you first enable searching for System Files; I've found it fastest to save such a search to the menu bar.
If this is a non-production app, just delete your local database (appname.sqlite) and restart the app.
Delete your app on simulator and restart:
On simulator, go to Hardware -> Home:
Click and hold mouse button on your application icon:
Click on "X" in app icon to delete:
Go back to Xcode and restart your application(Command+R):
or:
PS.:
If the error appears again, review your code because the problem should be in the syntax or discrepancy between what you want to list with the data model that you have.
Reset your simulator and run again. If you were to run with a different device in the simulator, it would work. If you are running with an iphone 6s simulator and you try to run 6s plus, it would still work without resetting.
If running on a phone, make sure to delete the app and rerun it
I have faced the same issue using Xcode 7 beta 1 and the following action has resolved the issue.
Menu==>> click on Window>Projects>select project on the left hand side and click on delete button which is located on the right side.
If still doesn't work,
=> reset the simulator and run the app

MVC 3 EF Code-first to webhost database trouble

Im fairly new to ASP.NET MVC 3, and to coding in general really.
I have a very very small application i want to upload to my webhosting domain.
I am using entity framework, and it works fine on my local machine.
I've entered a new connection string to use my remote database instead however it dosen't really work, first of all i have 1 single MSSQL database, which cannot be de dropped and recreated, so i cannot use that strategy in my initializer, i tried to supply null in the strategy, but to no avail, my tables simply does not get created in my database and thats the problem, i don't know how i am to do that with entity framework.
When i run the application, it tries to select the data from the database, that part works fine, i just dont know how to be able to create those tabes in my database through codefirst.
I could probaly get it to work through manually recreating the tables, but i want to know the solution through codefirst.
This is my initializer class
public class EntityInit : DropCreateDatabaseIfModelChanges<NewsContext>
{
private NewsContext _db = new NewsContext();
protected override void Seed(NewsContext context)
{
new List<News>
{
new News{ Author="Michael Brandt", Title="Test News 1 ", NewsBody="Bblablabalblaaaaa1" },
new News{ Author="Michael Brandt", Title="Test News 2 ", NewsBody="Bblablabalblaaaaa2" },
new News{ Author="Michael Brandt", Title="Test News 3 ", NewsBody="Bblablabalblaaaaa3" },
new News{ Author="Michael Brandt", Title="Test News 4 ", NewsBody="Bblablabalblaaaaa4" },
}.ForEach(a => context.News.Add(a));
base.Seed(context);
}
}
As i said, im really new to all this, so excuse me, if im lacking to provide the proper information you need to answer my question, just me know and i will answer it
Initialization strategies do not support upgrade strategies at the moment.
Initialization strategies should be used to initialise a new database. all subsequent changes should be done using scripts at the moment.
the best practice as we speak is to modify the database with a script, and then adjust by hand the code to reflect this change.
in future releases, upgrade / migration strategies will be available.
try to execute the scripts statement by statement from a custom IDatabaseInitializer
then from this you can read the database version in the db and apply the missing scripts to your database. simply store a db version in a table. then level up with change scripts.
public class Initializer : IDatabaseInitializer<MyContext>
{
public void InitializeDatabase(MyContext context)
{
if (!context.Database.Exists() || !context.Database.CompatibleWithModel(false))
{
context.Database.Delete();
context.Database.Create();
var jobInstanceStateList = EnumExtensions.ConvertEnumToDictionary<JobInstanceStateEnum>().ToList();
jobInstanceStateList.ForEach(kvp => context.JobInstanceStateLookup.Add(
new JobInstanceStateLookup()
{
JobInstanceStateLookupId = kvp.Value,
Value = kvp.Key
}));
context.SaveChanges();
}
}
}
Have you tried to use the CreateDatabaseOnlyIfNotExists
– Every time the context is initialized, database will be recreated if it does not exist.
The database initializer can be set using the SetInitializer method of the Database class.If nothing is specified it will use the CreateDatabaseOnlyIfNotExists class to initialize the database.
Database.SetInitializer(null);
-
Database.SetInitializer<NewsContext>(new CreateDatabaseOnlyIfNotExists<NewsContext>());
I'm not sure if this is the exact syntax as I have not written this in a while. But it should be very similar.
If you are using a very small application, you maybe could go for SQL CE 4.0.
The bin-deployment should allow you to run SQL CE 4.0 even if your provider doesn't have the binaries installed for it. You can read more here.
That we you can actually use whatever initializer you want, since you now don't have the problem of not being able to drop databases and delete tables.
could this be of any help?

Resources