How to prevent Glass Mapper doing Sitecore fast query? - sitecore

When I do the ISitecoreContext.Query, if the query contains the [##templatename='some_name'], for example:
"/sitecore/Content/Home/*[##templatename='some_name']"
the query result follows the order in content tree.
Otherwise, like the following:
"/sitecore/Content/Home/*"
the sorting doesn't follow the content tree order.
Does Glass Mapper switch to Sitecore fast query automatically and how to prevent this happening? (Better I don't have to resolve this in the sort order field way...)

Glass does not change the sort order of items in a tree list, so I am unsure what is causing this. Also Glass does not use fast query unless you instruct it to.
The best way to test if this is a Glass bug or not is to use the raw Sitecore API. To test you query use Database.SelectItems and to test the tree list use the standard Sitecore.Data.Fields.MultilistField.
If you do notice a difference between what SC and Glass return then please raise a bug on Github.

Related

Efficient way to grab all items form ContentSearchManager SearchIndex in Sitecore?

using (var context = ContentSearchManager.GetIndex(index).CreateSearchContext())
{
var items = context.GetQueryable<SearchResultItem>()
.Where(item => item.TemplateId == _templateId)
.ToList();
var resultList = new List<MediaItem>();
I then go through and use conditionals to filter the results more and add them to resultList.
I add them to the list with (MediaItem)x.GetItem();
I have terrible performance, which I am sure is caused by GetItem querying the database 10,000s of times.
I need to have the results as a MediaItem due to needing to edit the fields in these items.
How can I avoid querying Sitecore for each item with GetItem() ?
Thanks,
Sitecore Noob
I tried using .GetItem() with poor performance. I also tried researching how to get back Items instead of SearchResultItem
Yes, this would be a very slow and ineffective way of loading the needed items, since you're basically loading references to all media items of the given type into memory from Solr (GetQueryable<T>) and then load everything again from the database through .GetItem(). But the pattern you're trying isn't too far off actually.
Using the SearchContext, you should do the filtering in where you get all items references you need, letting Solr do the computation. I.e. not the 10,000s of items, just the ones you're editing. Once you get the filtered result back from Solr, you perform the .GetItem() on the items you want to work with. Always check that the item (and version) actually exists after a .GetItem() since the Solr index can sometimes be out of sync with the database, so a Solr response can in rare cases reference an item that doesn't exist.
How you should write the Solr query is a bit hard to describe without knowing more details about what filters you need. In general, I'd recommend using the SolrNet API directly instead of going through the ContentSearchManager wrapper. It's sometimes hard to understand what the search manager does under the hood and you basically need to monitor the Search.log in order to verify that your code does what it's supposed to do. A small mistake in the .Where() could cause the entire media library to be loaded into memory and you'll experience the same performance issue again as you have right now. With the query you have today, it's worth noting the difference between the underlying _template and _templates index fields, as the first one (that's used in your sample code) will return items of exactly that given template while the later one will also include all items inheriting from that template.

How to design a relational schema to show a list of posts and show if I have liked it or not (like Facebook)?

I would like to show a list of items/ posts. However, this list should be accompanied by a like/vote/some other action button. If the user has already done this action it should be marked in the list.
I am not sure that every time, retrieving the list of items(item ids) I have liked/voted should be retrieved and the (list of)posts be checked against it.
Alternatively a non-relational schema may be available. However, I want to efficiently implement this in a relational setup.
I don't know which technology you 'll use to create your application but for me today the best way is to begin with the object model and relational model could be generate and the same for non-relational schema.

Performance issue when typing into search input when retrieving objects from store

I have a search field, which lets the user search books (filters records, which are retrieved with ember-data).
I have found that any access the store from the results computed property within my component (see jsbin) makes the typing into the search field very slow (noticeable on my PC, and terrible on smartphone).
Here is a screenshot of the Timeline pane when typing a search query. The displayed part show that every keypress causes A LOT of layout (the search field seems to rerendered on every keypress). I also provide the exported timeline which you can load into your dev tools as explained here
I have tried to recreate the issue in a jsfiddle, but it seems to work just fine. The difference might be that in the jsbin I am using fixtures, while in my app I retrieve data from a real API.
I don't understand what is causing this behavior. It may be hard to come to any conclusion from the data I can provide, but does anyone have any ideas? Has anyone experienced similar performance issues?
Update 2014-03-01
I should note that the performance hit only happens if the results computed property contains a call to the store. If I replace it with any other thing (like just returning [], or some random async method -- like $.get) it not display this performance hit.
Additionally, I should make it clear (in case you didn't read the code), that the results computed property is not called on every keypress, but only when the search is submitted.
This is not a Ember/Ember-data bug, but apparently a Google Chrome bug.
I have created a new question regarding the issue here

PL/SQL Access to Saved Report Data

Using 4.1 (latest version).
I have an Interactive Report page in my app. Users are free to create and save public and private reports setting any filter conditions they choose. What I need to do is loop through these reports and "process" some data based on a column value that matches the filter condition (something like an EMPLOYEE_ID).
What I would like to do is package this functionality into a PL/SQL procedure that is scheduled using DBMS_SCHEDULER.
Other than trying to reverse engineer this from the APEX views, I am stuck. Any help is greatly appreciated.
The bad news: there is no built-in way to get the query of an interactive report.
(I hope you can program PLSQL, otherwise you've hit a dead end.)
However, i have a package which does most of the work and is indeed processing the application metadata for IRs. It can handle both column and row filters, and also columns which have an lov laid on top of them. It doesn't handle computations or aggregates.
You'd have to take the code and adjust it somewhat though, as my goal was returning some data through json back to the browser, but you won't have to write the query-rebuilding part anymore. I'll refer you to my blog post i made about my package and why i made it, so that might clear up some of the usage of it for you. You can get the zip, and you'll need the APEX_IR package. (at time of writing, it still contains a stupid oversight in that it ignores the dis/enabled state of filters)

Google Search Results In SiteCore

I have a Google Mini setup to index a SiteCore site. I have XSLT configured to display my search results, as desired.
How do I get this XSLT into a search results page in SiteCore? I have it setup as a rendering, but it seems to break every time. Has anyone done something similar, and have an idea of how to set it up and how the parameters should be?
It looks like this isn't possible.
Here's the thread from the CTO of sitecore.
http://sdn.sitecore.net/forum//ShowPost.aspx?PostID=37004
I'm trying to understand your situation... To me it looks like you've copied the XSLT from the mini and pasted it into sitecore, is that right? I haven't done that but if you're going to render the results in sitecore you need to get the XML results from the mini. You do that by removing the proxystylesheet parameter and it's accociated value in tje request URL. Have you done that?