redisTemplate.opsForHash().get ("CAR", name);
so we get the car by name.
redisTemplate.opsForHash ().put ("CAR", "TOYOTA", "PRIUS");
This is how we write data to REDIS.
That is, using TOYOTA and CAR we can get PRIUS.
Now, I should understand how to record and find data by a pair of keys. For example, I should find a car not only by brand ("TOYOTA") but also by color.
redisTemplate.opsForHash () .put (" CAR "," TOYOTA "+" WHITE "," PRIUS ");
The question is how to use the second parameter?
redisTemplate.opsForHash (). get (" CAR ", name + color);
In my case, the pair name and color are unique and i need to search for them.
In case of searching by one value, everything works fine, but it is not clear how to search by two parameters.
thanks in advance
Just maintian different cars and cars with colors in the hash.
Map<String,String> map = new HashMap<>();
map.put("TOYOTA","PRIUS");
map.put("TOYOTA:WHITE","PRIUS-w");
map.put("TOYOTA:YELLOW","PRIUS-y");
redisTemplate.opsForHash().putAll("CAR",map);
Related
I have a field subspecialty that can contain multiple values as a string separated by commas.
I am trying to get the sum of another field ('topic_ids) grouped by the values in subspecialty`. In other words... number of topics completed grouped by subspecialty, but there are multiple subspecialties listed in the field in each row.
So far I've managed to use split to separate subspecialty values into different fields.
There are up to five values in the field at once, so I created 5 different custom fields.
split({subspecialty[flattened_content]},',',1)
split({subspecialty[flattened_content]},',',2)
split({subspecialty[flattened_content]},',',3)
split({subspecialty[flattened_content]},',',4)
split({subspecialty[flattened_content]},',',5)
so something like subspecialty[flattened_content] = {Neuro, Emergency, Head and Neck, Vascular, Physics}
becomes
subspecialty_split_1 = "Neuro"
subspecialty_split_2 = "Emergency"
subspecialty_split_3 = "Head and Neck"
subspecialty_split_4 = "Vascular"
subspecialty_split_5 = "Physics"
with these fields split, I can now create additional custom fields to count topic_id where any one of subspecialty_split_n fields = a particular value.
countIf
(
{topic_id},
{subspecialty_split_1} = "Neuro"
OR
{subspecialty_split_2} = " Neuro".
OR
{subspecialty_split_3} = " Neuro"
OR
{subspecialty_split_4} = " Neuro"
OR
{subspecialty_split_5} = " Neuro"
)
This has at least allowed me to create a table that counts topic ID by individual subspecialties, but because they are custom aggregations, I can't do anything like sorting, using charts, etc.
I have two columns called Quantity and Issued Quantity. I want that when I put value in Quantity column, for instance 3, the Issued Quantity will automatically generate 3. Also I want it to happen the other way around.
The example is on Purchase Order window, PO Line tab. in Quantity section. When I put 4 in Quantity field, the PO Quantity field automatically generate 4.
I try to imitate the column and field but it doesn't work.
This is accomplished in Adempiere by a Callout which is configured in what Adempiere calls the Application Dictionary
From the example you gave; updating the qty on the Purchase Order.
If you login to Adempiere using the System user, you can view and modify the Application Dictionary.
From the main menu select Application Dictionary->Table & Column.
In the Search box that opens enter C_OrderLine as the DB Table name.
Now Column tab and scroll down the list to locate the QtyEntered column. Switch to the Form view and near the end you will see were you can enter the field Callout.
You should see that the C_OrderLine.QtyEntered field already has a value "org.compiere.model.CalloutOrder.qty; org.compiere.model.CalloutOrder.amt" which indicates it should run the method qty in the class org.compiere.model.CalloutOrder followed by the method amt in the org.compiere.model.CalloutOrder class.
If you open those classes you can see how easily you can evaluate and modify values. Breaking some of of it down for you... if you open the CalloutOrder.java class you cab scroll down until you find the qty method.
public String qty (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
You need use the signature as above for any new callout method you create. Follow that approach and Adempiere will look after passing the correct values for you
if (isCalloutActive() || value == null)
return "";
It's good practice to start the method with the above ensure you do not open a Callout from within a Callout - which would break the Adempiere rules.
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
Is an example of how you could extract values from the existing window... the syntax would remain the same regardless of Column/Field the you just need to enter the "M_Product_ID" which is the Field name you wish to extract to use.
Now this Callout is called by more than one Column/Field so it is littered with a big if...then...else to executed the logic needed for the relevant field. It's not pretty, but this is aimed at business developers who will concentrate more on business logic than coding principals.
The code you are interested in is
else if (mField.getColumnName().equals("QtyEntered"))
{
int C_UOM_To_ID = Env.getContextAsInt(ctx, WindowNo, "C_UOM_ID");
QtyEntered = (BigDecimal)value;
BigDecimal QtyEntered1 = QtyEntered.setScale(MUOM.getPrecision(ctx, C_UOM_To_ID), BigDecimal.ROUND_HALF_UP);
if (QtyEntered.compareTo(QtyEntered1) != 0)
{
log.fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
+ "; QtyEntered=" + QtyEntered + "->" + QtyEntered1);
QtyEntered = QtyEntered1;
mTab.setValue("QtyEntered", QtyEntered);
}
QtyOrdered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, QtyEntered);
if (QtyOrdered == null)
QtyOrdered = QtyEntered;
boolean conversion = QtyEntered.compareTo(QtyOrdered) != 0;
log.fine("UOM=" + C_UOM_To_ID
+ ", QtyEntered=" + QtyEntered
+ " -> " + conversion
+ " QtyOrdered=" + QtyOrdered);
Env.setContext(ctx, WindowNo, "UOMConversion", conversion ? "Y" : "N");
mTab.setValue("QtyOrdered", QtyOrdered);
}
The code
mTab.setValue("QtyOrdered", QtyOrdered);
Is where it sets the value of the other quantity field Qty Ordered.
Also, the call must not be Java. It is possible to link any [JSR223 script][3]. I never actually tried this approach myself, but it is even possible to implement Callouts using the Drools Rules Engine!
i am a beginner & developing my very first project with lucene.net i.e. an address search utility, lucene.net 3.0.3
using standard analyzer, query parser, (suppose i have a single field, Stored & Analyzed as well)
- sample data : (every row is a document with a single field)
(Postcode and street column concatenated)
UB6 9AH Greenford Road something
UB6 9AP Greenford Road something
UB1 3EB Greenford Road something
PR8 3JT Greenford Road something
HA1 3QD something Greenford Road
SM1 1JY something Greenford Road something
Searching
StringBuilder customQuery = new StringBuilder();
customQuery.Append(_searchFieldName + ":\"" + searchTerm + "\"^" + (wordsCount));
// this is for phrase matching
foreach (var word in words.Where(word => !string.IsNullOrEmpty(word)))
{
customQuery.Append(" +" + _searchFieldName + ":" + word + "*");
}
// this is prefix match for each word
Query query = _parser.Parse(customQuery.ToString());
_searcher.Search(query, collector);
all above (searching) working fine
Question
if i search for "Greenford road" ,
i may want that row that has 'SM1' should come up (means i want to priorities result as per postcode)
i have tested Query-Time-Boost and it works fine
but i may have a long list of priority postcodes sometimes (so i don't want to loop over each postcode and set its priority at query time
I WANT DOCUMENT TIME BOOSTING
but whatever document boost i set (at the time of indexing), it doesn't effect my search results
doc.Add(new Field(SearchFieldName, SearchField, Field.Store.YES, Field.Index.ANALYZED));
if (condition == true)
{
doc.Boost = 2; // or 5 or 200 etc (nothing works)
}
please HELP
i tried to understand similarity and scoring, but its too much mathematics there...
please help....
I recently had this problem myself and I think it might be due to wildcard queries (It was in my case at least). There is another post here that explains the issue better, and provides a possible solution:
Lucene .net Boost not working when using * wildcard
I'm using hadoop streaming to do some job, and I encounter a problem, here it is.
The input file to mapper has, say 3 fields, in each line. I know that mapper's output will be sorted and partitioned before feeding the data to reducer, and my problem is
1.Can I sort/partition those data using the 3rd field?
2.Can I sort the data using the whole line?
PS:
AFAIK, the sort-key or partition-key should be the first k fields of each line, right? If so, does it mean I should move those fields into the front of line in mapper?
Mapper's output are sorted only on the basis of the key.
So, say you have input record as : field1, field2 ,field3
1) if you do not want to the first field to be your key and can manage if your 3rd field is key then you do not need to do anything else, so you can do something like follows:
output.collect(new Text(field3), new Text(field1 + ","+field2)); //Old API
context.write(new Text(field3), new Text(field1 + ","+field2)); //New API
2) Similarly you can have everything as your key and null as value, this would result in getting sorted as per whole line, something like follows can be done:
output.collect(new Text(field1 + ","+field2 + "," + field3), null); // Old API
context.write(new Text(field1 + ","+field2 + "," + field3), null); // New API
No, it doesn't matter at all in which sequence the fields are in the input file as far as the sorting is concerned, it is only depended on what are you emitting from the mapper as mapper output.
But if you need to have field1 as your key in mapper output but want to do a secondary sort on field3, then read : How to do a secondary sort on values ?
Hi I have 2 problems related to hibernate criteria
I have the following product which contain many colors.
I wish to find the product which contain at least RED and GREEN.
Product class
String id;
name;
style;
List<Color> colors{};
Color class
id
color
1) Every time I do a retrieval, each product will appear depending on how many colors it has..
for example a product A has red green blue, it will appear 3 times.
I have used FetchMode: Select but it doesn't seems to change.
The only possible solution I can think of is inserting them into a hashset and rewrite the hashcode and equal method for primary key only
2) How do I return queries that is sorted according to the closest match to my search?
For example I search for style and color red,green.
so products that matches style color and red green
1) You use need to distict results.
It is not a matter of changing FetchMode.
Please take a look article this
setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
2) Well... there is no that kind of criteria function to automatically find and order closest match stuff
Anyway, the simplest way to make similar function is to use addOrder with createAlias instead of setFetch
ct.createAlias("colors", "cs")
.add( Restrictions.like("style", value + "%"))
.add( Restrictions.in("color", colorsArray ))
.addOrder( Order.asc("style"))
.addOrder( Order.asc("cs.color"))
I cannot write all kind of match method in here.
Please refer Restrictions's various expression on here