A business requirement dictates that for implementing a full text search solution, that certain fields being searched have more weight than others. Although I have found that you can add weight to the search terms themselves, I'm not sure it satisfies our need.
Let me provide the basic setup, and perhaps I'm missing something in the setup, rather than at query time, or both?
Basic setup to create an Oracle Text index using multicolumn datastore.
I create a table of 40 columns, from name to address, phone number, business, etc.
create table full_search_tab
( id integer
, dummy_search_col char(1)
, first_name varchar2(30)
, middle_name varchar2(30)
, last_name varchar2(50));
I then create a preference for the datastore (in actuality I will include all 40 columns in the columns list, but only list a few for demonstration):
exec ctx_ddl.create_preference('multi_ds', 'MULTI_COLUMN_DATASTORE');
exec ctx_ddl.set_attribute('multi_ds', 'columns', 'LAST_NAME,FIRST_NAME,MIDDLE_NAME');
I create the index:
create index full_search_mcds_ctx_idx on full_search_tab(dummy_search_col) indextype IS ctxsys.context
parameters ('datastore multi_ds');
Now when I query the index this will behave like a Google like search. We will pass the free form text to a query where all terms use AND operator. We want the hits on certain columns to be weighted higher than others => delivering a modified scoring. For example, we always want the column last_name when matched on any of the terms to be weighted higher than all others, and middle_name to be weighted lower.
What I'm uncertain of, is it possible to do this? Is it done with preferences prior to indexing? Or is it with every query?
For those familiar with Elasticsearch querying, I would like to replicate this query syntax using Oracle Text if possible:
GET full_search_mcds_ctx_idx/_search
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"type":"cross_fields",
"query": "john m smith",
"operator": "and",
"fields": [
"LastName^2",
"MiddleName^0.2",
"FirstName^1.2"]
}
}
]
}
},
"size": 0
}