Dynamic search in ADF - jdeveloper

I have a search page with multiple search options(input text boxes) Based on the search criteria entered , I need to create a dynamic search query. (I need search results based on the fields for which user inputs some value)

or you can use <af:quickQuery> for a simple search. Here's the sample code taken from Oracle demo.
<af:quickQuery label="Search" id="search" searchDesc="search" binding="#{editor.component}" value="#{demoQuickQuery.queryDescriptor}" queryListener="#{demoQuickQuery.processQuery}">
</af:quickQuery>

If you are using ADF/BC, this is built-in. Just use the <af:query/> component.

af:query is the more robust of the two query components, but does require you create a viewcriteria object in the VO that will be the basis for the query. However it is very powerful: dynamically add new attributes to the query at runtime, change query rules (starts with, contains, etc)
af:quickquery allows you to choose one and only one attribute to query on at a time.
Please note: these components (and the executewithparms) are the only supported query methods in ADF Faces 11g

Related

Elastic Search and Search Ranking Models

I am new to Elastic Search. I would like to know if the following steps are how typically people use ES to build a search engine.
Use Elastic Search to get a list of qualified documents/results based on a user's input.
Build and use a search ranking model to sort this list.
Use this sorted list as the output of the search engine to the user.
I would probably add a few steps
Think about your information model.
What kinds of documents are you indexing?
What are the important fields and what field types are they?
What fields should be shown in the search result?
All this becomes part of your mapping
Index documents
Are the underlying data changing or can you index it just once?
How are you detecting new docuemtns/deletes/updates?
This will be included in your connetors, that can be set up in multiple ways, for example using the Documents API
A bit of trial and error to sort out your ranking model
Depending on your use case, the default ranking may be enough.
have a look at the Search API to try out different ranking.
Use the search result list to present the results to the end user

AWS Quicksight calculated field vs Custom SQL query

As with any other BI tool AWS Quicksight allows you to add calculated fields. So far, I haven't run into any limitations using them, but I can't help but wonder what is the better design approach? Adding a calculated field in my custom SQL query or using the calculated fields feature?
So there is a few ways to work with calculated fields in Quicksight:
You do them in your SQL query
You add them to your dataset
You add them to your analysis
I am not sure if this would be considered best practice, but my preference has evolved to:
Use calculated fields on an analysis, if I want to contain that field to the analysis only.
If the field will be used more than once, I add them to the dataset. This is my go-to method if I am not using a direct query and relying on the default UI.
For any complicated calculations that are not supported by Quicksight calculated fields or if I am already using a direct query, I'll do everything in SQL.
The downside of calculated fields is that looking up their computation can be a little annoying as it involves a few clicks. Also, I find it hard to differentiate between which fields are calculated and which aren't so I have a habit of prefixing calculated fields with _, e.g. _date or _day_of_week if it is a calculated field.

faster search for a substring through large document

I have a csv file of more than 1M records written in English + another language. I have to make a UI that gets a keyword, search through the document, and returns record where that key appears. I look for the key in two columns only.
Here is how I implemented it:
First, I made a postgres database for the data stored in the CSV file. Then made a classic website where the user can enter a keyword. This is the SQL query that I use(In spring boot)
SELECT * FROM table WHERE col1 LIKE %:keyword% OR col2 LIKE %:keyword%;
Right now, it is working perfectly fine, but I was wondering how to make search faster? was using SQL instead of classic document search better?
If the document is only searched once and thrown away, then it's overhead to load into a database. Instead can search the file directly using the nio parallel search feature which uses multiple threads to concurrently search the file:
List<Record> result = Files.lines("some/path")
.parallel()
.unordered()
.map(l -> lineToRecord(l))
.filter(r -> r.getCol1().contains(keyword) || r.getCol2().contains(keyword))
.collect(Collectors.toList());
NOTE: need to provide the lineToRecord() method and the Record class.
If the document is going to be searched over and over again, then can think about indexing the document. This means pre-processing the document to suit the search requirements. In this case it's keywords of col1 and col2. An index is like a map in java, eg:
Map<String, Record> col1Index
But since you have the "LIKE" semantics, this is not so easy to do as it's not as simple as splitting the string by white space since the keyword could match a substring. So in this case it might be best to look for some tool to help. Typically this would be something like solr/lucene.
Databases can also provide similar functionality eg: https://www.postgresql.org/docs/current/pgtrgm.html
For LIKE queries, you should look at the pg_trgm index type with the gin_trgm_ops operator class. You shouldn't need to change query at all, just build the index on each column. Or maybe one multi-column index.

Per user behavior based scoring in Elasticsearch

We do understand the behavior of user by analyzing the tags he usually search for.
Now we need to give higher precedence for such tags for these users. I would like to know how we can achieve this using Elasticsearch in an elegant manner.
Well the best approach for this would be to
Analyse the behavior of the user
See which all keywords are of his interests
Maintain one document per user in another index which have all these keywords.
On the searches for that user , boost the occurrence of these keywords using function_score query
You can use terms filter inside boost function to achieve this.Add the boost function under functions in the function score query
In terms filter , you can point to this users document and get the values dynamically
Use custom filter key so that the cache key constructed wont eat too much memory
In this approach , you can avoid lots of code paths in client code.

jqgrid search functionality

I am using jqgrid Advanced Search functionality in my project. I want to display the first overall row at all times irrespective of search. Is there a way how I can achieve this?
What do you mean by first overall row?
Are you fetching details from a list or from a database?
You can use a Dataprovider object and use it's setSort method..
If the data is coming from a database this can easily be done by using the sort property to pass it as the sort by property in your sql statement, if you're using a list you can use Collections.sort() but your list object has to have a sorting algo that it should follow..

Resources