SAP HANA CDS View Fuzzy Search not working - hana

I have a HDBDD defined as such, but the fuzzy search I tried using the query below doesn't work. Only maps to full text like "Singapore".
https://xxxxxxxx.xxx.xx.xxxxx.com/xxxxx.xsodata/LandValue?$format=json&search=singaporw
namespace xxx;
#Schema : 'XXX'
context fuzzysearch {
#Catalog.tableType : #COLUMN
entity ADDRESS {
key id : Integer;
street : String(80);
zipCode : Integer;
city : String(80);
#SearchIndex.text.enabled : true
#SearchIndex.fuzzy.enabled : true
country : String(80);
};
#Search.searchable: true
define view V_ADDRESS as select from ADDRESS as ADDRESS {
#EnterpriseSearch.key : true
ADDRESS.id,
#Search.defaultSearchElement: true
#Search.ranking: #HIGH
#Search.fuzzinessThreshold : 0.7
ADDRESS.country
};
};

Looks like you are using this as your base example?
Try changing your fuzzy threshold to like .8 or .87
https://xxxxxxxx.xxx.xx.xxxxx.com/xxxxx.xsodata/LandValue?$format=json&search=singporw
Now if the only country in your dataset is Singapore then you will get everything every time of course.

Related

select model B with model A column name condition in laravel model

I have two models with different name and columns but the purpose/data of the two models is the same, namely, it contains the employee's name, here the model
Employee
name
code
country
city
John
A1
USA
NYC
Doe
A2
USA
LA
New_Employee
v_fullname
v_code
v_country
v_city
Mark
ZZ1
USA
LS
Zuc
FF2
USA
LS
as you can see the column name is different but the purpose is identical. I want to select data from New_Employee but use column name from Employee, so the query will look like this
SELECT v_fullname as name, v_code as code, v_country as country, v_city as city
FROM New_Employee
WHERE name = 'Mark'
Sorry if my explanation is hard to understand, but here's the code I have tried
SyncEmployee model (this model is like a bridge connecting employee and new_employee model)
<?php
namespace App\Models;
use App\Models\Employee;
use App\Models\NewEmployee;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class SyncEmployee extends Model
{
use HasFactory;
protected $connection = 'mysql_2';
public const TABLE_NAME = 'new_employee';
public function index()
{
$data = NewEmployee::select('v_fullname as name, v_code as code, v_country as country, v_city as city')->get();
return view('view_name', compact('data'));
}
}
I thought with that code when I call SyncEmployee::where('code', '=', 'ZZ1') from controller, the result will
name
code
country
city
Mark
ZZ1
USA
LS
*The data is from New_Employee but the column name using Employee
You could attempt to use the ability to hide or append attributes at serialization to do most of the work for you. You would need to define accessors and mutators and define what is 'hidden' and 'appended' for serialization:
use Illuminate\Database\Eloquent\Casts\Attribute;
class NewEmployee extends Model
{
...
protected $table = 'new_employee';
protected $hidden = [
...
'v_fullname',
'v_code',
'v_country',
'v_city',
];
protected $appends = [
...
'name',
'code',
'country',
'city',
];
protected function name(): Attribute
{
return Attribute::make(
get: fn () => $this->attributes['v_fullname'] ?? null,
set: fn ($v) => $this->attributes['v_fullname'] = $v
);
}
...
}
If you are not using the Model's data after serialization you can still access these fields:
// will hit the accessor
$newEmployee->code;
// will hit the mutator
$newEmployee->code = 'blah';
Laravel 9.x Docs - Eloquent: Mutators and Casting - Accessors & Mutators
Laravel 9.x Docs - Eloquent: Serialization - Hiding Attributes From JSON
Laravel 9.x Docs - Eloquent: Serialization - Appending Values to JSON

DDL source Z1127_EXTVIEW of type ABAP Dictionary Type cannot be converted to Extend (-> long text)

I have the table Z1127_STUDENT:
define table z1127_student {
key id : z1127_sample not null;
branch : z1127_sample1;
age : z1127_age;
address : z1127_address;
percentage : z1127_percent;
}
(the types of the columns are based on the types int2 and char)
and the CDS view Z1127_CDS_VIEWS:
#AbapCatalog.sqlViewName: 'Z1127_CDSVIEWS'
#AbapCatalog.compiler.compareFilter: true
#AbapCatalog.preserveKey: true
#AccessControl.authorizationCheck: #CHECK
#EndUserText.label: 'CDS VIEWS'
define view Z1127_CDS_VIEWS as select from z1127_student
{
key id,
branch,
age
}
I tried to create this extended view :
#AbapCatalog.sqlViewAppendName: 'Z1127_SQL_3'
#EndUserText.label: 'cds view 3'
extend view Z1127_CDS_VIEWS with z1127_cds3 {
address,
percentage
}
But it's showing this error :
DDL source z1127_cds3 of type ABAP Dictionary Type cannot be converted to Extend (-> long text)
How to avoid this error?

The Elm way of transforming flags to model

I have the following types in my app:
type Page
= Welcome
| Cards
type alias Flags =
{ recipientName : String
, products : List Product
}
type alias Product =
{ id : Int
, name : String
, price : Float
, liked : Maybe Bool
}
type alias Model =
{ recipientName : String
, currentPage : Page
, products : List Product
}
I am passing an array of products as flags. Here's what my init looks like:
init : Flags -> ( Model, Cmd Msg )
init flags =
let
{ recipientName, products } =
flags
in
Model recipientName Welcome products
|> withNoCmd
The challenge I'm facing is that the products in this array only have id, name, and price attributes. So, given the Flags definition, every time I extend Product with a new attribute (such as liked), the array of products passed as flags will need to have that attribute as well. For now, I just render them as empty, but this doesn't feel right, so I was wondering what is the Elm way™ of receiving flags and transforming them into the model? Thank you!
It sounds like your Product is already defined as an input (or the environment) of your app:
type alias Product =
{ id : Int
, name : String
, price : Float
}
and you are augmenting this with info that relates the Recipient to the Products. I'd suggest splitting this out into its own type that can grow as your app grows, eg:
type alias Opinion =
{ liked : Maybe Bool
, review : String
, preferredColor : Color
}
then you can tie these together in your Model:
type alias Model =
{ recipientName : String
, currentPage : Page
, products : List (Product, Opinion)
}
or, depending on how the application works, you might end up wanting to look up the recipient's opinion by product.id:
...
, products : List Product
, opinions : Dict Int Opinion
The point is that if you keep the original Product unchanged, you can build a small library of functions that work on Product, both for inventory (where no recipient is involved) and for the customer. Maybe you can re-use the Opinion type for customer metrics.
If these two types are likely to evolve, keeping them separate can help ensure you don't end up with messy and bug-attracting interdependencies.

Add record in listGrid with variable

I am adding record in grid using startEditingNew method as below.
var COLUMN_NAME = {
name : "user_name",
lastname : "user_surname",
age : "user_age"
};
addDataToGrid : function (name, lastname, age){
MyGrid_Grid.startEditingNew({
COLUMN_NAME.name: name,
COLUMN_NAME.lastname: lastname,
COLUMN_NAME.age: age
});
}
But, my above function raise error and does not add record to grid.
If I use "user_name" string instead of "COLUMN_NAME.name" , It works fine.
How can I use variable as column name??
Thanks in advance
This is a javascript question, not a SmartClient one.
Anyway, if you need to use that approach, you may write something like:
addDataToGrid : function (name, lastname, age){
var record = {};
record[COLUMN_NAME.name] = name;
record[COLUMN_NAME.lastname] = lastname;
record[COLUMN_NAME.age] = age;
MyGrid_Grid.startEditingNew(record);
}
see also Rules for unquoted JavaScript Object Literal Keys?

How to get value of nested Map using parameter

I'm trying to get value of nested Map using parameter of SQL component expression but it failed.
I have this json (unmarshal to java.util.Map):
{ "username" : "john",
"company" : { "companycode" : "stackoverflow.inc",
"address" : "Street 12" }
}
And I have this SQL expression with parameters on my Route builder:
...
.unmarshal().json(JsonLibrary.Jackson)
.to("sql:INSERT INTO user_tab VALUES (:#username, :#company.companycode)")
...
I was able to get the value of username but I can not get the value of companycode. What is the right way to do it? Thank you.
according: http://camel.apache.org/sql-component.html
From Camel 2.14 onward you can use Simple expressions as parameters as shown:
sql:select * from table where id=:#${property.myId} order by name[?options]
this work fine for me:
{guid=67, properties={last_seen=1472034553348, _type=business_service, name=Anna, created_at=1472033602648, status=USUNIĘTY}}
<to uri="dbSQL:insert into table_name (
guid,name,description,type,status,changedate,transid,transseq
) values (
:#${body[guid]}::integer, :#${body[properties][name]}, :#${body[properties][name]}, :#${body[properties][_type]}, :#${body[properties][staus]}, now(), 0, 0
)"/>