Say I have the given document structure in RavenDb
public class Car {
public string Manufacturer {get;set;}
public int BuildYear {get;set;}
public string Colour {get;set;}
public string Id {get;set;}
}
When the user searches for all cars of colour Red and build year 2010, I want to show them a grouping for manufacturer as such:
Toyota (12)
Mazda (30)
Given there are 12 toyotas and 30 mazdas that are red in colour and build year 2010.
This is a simplified use case. The user can really specify tons of criteria for the cars they want to match. Once I have a list of cars matching that criteria then I need to group that result set on every feature and show a count.
Its like a MapReduce but on a subset of data.
Afif, what you mean is called a faceted search. Thanks to the underlying Lucene.NET component RavenDB is very good at that. Take a look here: http://ravendb.net/documentation/faceted-search
Related
I'm using the ODOO pricelist for sales.order and invoice. The issue i'm facing is : I create a PRICELIST, and add PRODUCT-X with a rule of NEW PRICE = BASE PRICE(PUBLIC PRICE) x (23%) where the Product's Sale Price in Warehouse is set to let's say 770 and the discount is 23 percent - The discount gets applied to 770 the first time = 592.9- then once the product is added for a second time the 770 is no longer used as a base price, but the 592.9 is used and a 23 percent discount is applied and so forth...
So we have non-stable PRODUCT_X Public Price.
Please view the image below to get a clear picture of what goes on, i want the PUBLIC PRICE to not change automatically... If someone could give me advice, or if there's any module out there on the Odoo apps..
**NOTE IN THE IMAGE BELOW: the PRIX PUBLIC field is French for LIST PRICE
& the REMISE field is DISCOUNT
Now at the end we will have a look at the Product's PUBLIC PRICE and it will be 351.53 instead of 770 (we set at the beginning).
Thanks alot,
PROBLEM SOLVED
I removed this code in my sale_order.py
product_obj = self.pool.get('product.product')
if 'price_unit' in vals:
for this in self.browse(cr,uid,ids,context):
if this.product_id:
price_unit = vals.get('price_unit',0.0)
if this.product_id.lst_price != price_unit:
product_obj.write(cr,uid,[this.product_id.id],{'lst_price':price_unit})
It was making the PUBLIC PRICE updated from the order line for every addition.
Thanks #CZoellner for your valuable help - a reminder that the process wasn't running normally.
I have created a list (dd) which contains instances of a class. I want to be able to perform queries on some of its attributes (eg. finding the smallest numeric value), but cannot find a way to do this using the functionality of the class (I feel like going back to analysing the data by column). How do I access the values in one of the attributes when my instances are now on a list? Thanks!
Assuming you're using C# and having a class like this
class Foo
{
public double Bar { get; set; }
}
then LINQ is exactly what you are looking for
List<Foo> list = GetList();
var filtered = list.Where(p => p.Bar > 23.0);
Have a look at these examples:
https://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b
We have a site with several queries that query the direct children of a content item. We simply want just the children sorted by the order they appear in the content tree.
We're using Glass Mapper and our collection properties look like this:
[SitecoreQuery("/sitecore/content/Global/Team Members/Categories/*")]
public IEnumerable<ICategory> Categories { get; set; }
The above property Categories returns the child items in what seems to be alpha order, but in some cases it seems a bit random.
Any idea how to set up the query to pull in the order of the content tree?
Scott,
I believe that Glass is using fast query for these SitecoreQueries which is why you aren't getting any predictable sort order. Unfortunately the fast query does not allow sorting in the query syntax. You will see the same if you put your query into the XPath Builder in Sitecore's Developer Center by using this syntax:
fast:/sitecore/content/Global/Team Members/Categories/*
I think the quickest way to resolve this is to just add Sitecore's __Sortorder field to your ICategory definition.
[SitecoreField("__Sortorder"),]
string Sortorder { get; set; }
You could then add another property to your model that returns the sorted version of this.
public IEnumberable<ICategory> SortedCategories { get { return Categories.OrderBy(s=>s.Sortorder); } }
Keep in mind you can also use the [SitecoreChildren] decorator to get the children of the current item. I'm not sure if that is actually what you are after, but that decorator will actually return your items in the correct order per Sitecore's SortOrder.
How do I get a sitecore item in Sitecore 7.2 by its field (of type droptree) value using Sitecore.ContentSearch?
I've tried: context.GetQueryable<SearchResultItem>().FirstOrDefault(resultItem=>resultItem["Field Name"]=="{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"); but no luck. Any tips?
Guids get indexed in a normalized format (lower case, no hyphens or braces). So if you want to search in this way, I think you need to normalize your search term.
See the 'slightly complex queries' section of this blog post:
http://www.xcentium.com/blog/2013/11/05/sitecore-7-linq-to-sitecore-simplified-part-1
By the way, if you do your query using a mapped POCO's rather than SearchResultItem then you can avoid having to manually do that normalization.
Try The following:
context.GetQueryable<SearchResultItem>().FirstOrDefault(resultItem=>resultItem["Field Name"]== Sitecore.ContentSearch.Utilities.IdHelper.NormalizeGuid("{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}");
Or just like martin suggested, you can create your own POCO class which have a property of your field with type (Sitecore.Data.ID):
public class MyOwnPoco : SearchResultItem
{
public Sitecore.Data.ID MyField {get;set;}
}
context.GetQueryable<>().FirstOrDefault(i=> i.MyField == Sitecore.Data.ID.Parse("{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"));
As I stated in the title I'd like to have a custom text field next to the price. For example I'd like to sell a bag of X by the bag (/bag) but another product is sold by /kg or /sqmeter). Now I only have the price on the product page.
Link to my webpage:
http://www.gerocskeramia.hu/webshop/
Use either the Options if this is something that needs price adjustments, or you could also use Attributes to add simple attributes like container type etc.