I'm trying to implement guided navigation using vespa. At present, I am using grouping to implement it. I've written a query like this.
SELECT * FROM entity where sddocname contains 'entity' | all(group(category) each(group(item_category) each(output(count()))));
In the above example category is like "electronics","automobiles" etc and "item_category" is like "mobile phone","car"etc.
I don't want to select any documents, I just wanted to see the grouped data. Is there a better way to solve this problem?
Use limit 0 to remove the plain hit list. Example here https://docs.vespa.ai/documentation/tutorials/blog-search.html
limit 0 in yql or just specify &hits=0
Related
Azure Search by default highlights search results with <em> tag. I've met with situation where user uploads document with that tag inside:
<em>Today</em> topic will be...
When i would search for "topic" i would get:
<em>Today</em> <em>topic</em> will be...
And i wouldn't be able to distinguish the right highlight.
I know that i can modify highlight_pre_tag and highlight_post_tag so i would avoid this in this particular situation. But is there other way to encode this tags before appyling highlighs?
EDIT:
By encoding i mean getting something like this:
<em>Today</em> <em>topic</em> will be...;
So I can send it to frontend and then display <em> from "Today" as <em> and use <em> in "topic" to highlight it to yellow.
Azure Search doesn't provide any built-in mechanism to modify the "raw" content of a document if you are using the Index API directly, however, if you are using one of our built-in indexers, you can look into using the field mapper functions (such as the UrlEncode function) or create your own custom skill (if you want to only apply very specific rules) to transform the documents in transit from your data source to the search index.
Alternatively, we've seen customers use custom highlight pre and post tags that are easily recognizable (and unlikely to be mistaken for original content) and then using a simple search and replace function in their client application to transform those back into the desired tag.
For example, using
pre-tag : "!HIGHLIGHT_START!" and post-tag :"!HIGHLIGHT_END!"
and then using
String.Replace("!HIGHLIGHT_START!", "<em>")
before displaying the results in their application. That way, any client-side logic that requires finding the actual highlights can use the custom tags, while still showing the desired tag in the UX.
I am experimenting IBM watsons' Discovery API to get data insights. I want to query using multiple filters. I am using python to accomplish the task. I have tried this for now, but this is not working.
qopts = {'filter':[{'enriched_text.entities.text:Recurrent Neural
Networks,Machine Learning classifiers'}]}
my_query = discovery.query(env_id, coll_id, qopts)
with only single entity : 'recurrent Neural Networks' through the discovery UI and through my python query, I get 3 documents from the collection.
but with two entities, 'Recurrent Neural Networks,Machine Learning classifiers', in the UI I get 2 documents but through my code, I get 2 documents.
Below is then right format which works for me. with multiple concept and keyword filters, I get a total of 2 search results, which match with the UI query
qopts = {'filter':{'enriched_text.concepts.text:"Neural network",enriched_text.keywords.text:"Neural Network",enriched_text.keywords.text:"generative conversational models"'}}
with only entity I get 3 match results
qopts = {'filter':{'enriched_text.concepts.text:"Neural network"'}}
in this example I am querying the documents with concept 'Neural network' , keywords 'Neural Network' and 'generative conversational models'
Inside Watson discovery documentation, inside the UI you'll use (according to the documentation):
But obviously, without the ! operator inside the second text.
and I think inside your code you need to use , between the values.
Not sure because I don't use the enriched_text.entities.textinside my filter, just the Strings.
One possible reference for another example to test:
filter=field1:some value,field2:another value
Official reference documentation: here.
I'm trying to paginate a union in cakephp 3. I have already found and read How do you modify a UNION query in CakePHP 3?, but am probably too new to cakephp to understand properly what is meant by "use a custom finder". I have read the relevant section in the cakephp book, but still fail to see how this helps to apply the epilog() to the query. Maybe someone could show a complete example?
I have two models Customers and Suppliers. I am trying to builds a search function that returns matching entries from both models, including pagination and sorting.
public function index($q=null) {
$this->loadmodel('Suppliers');
$this->loadmodel('Customers');
$customers=$this->Customers->find('all')->select(['type'=>"'Customers'",'id'=>'id','name'=>'name','phone'=>'phone'])
->where(['name like'=>'%'.$q.'%']);
$suppliers=$this->Suppliers->find('all')->select(['type'=>"'Suppliers'",'id'=>'id','name'=>'name','phone'=>'phone'])
->where(['name like'=>'%'.$q.'%']);
$customers->union($suppliers);
$results=$this->paginate($customers);
$this->set(compact(['q','results']));
}
As detailed in How do you modify a UNION query in CakePHP 3?, this results in the order,limit and offset only being applied to the first select.
Removing the paginate() and applying order,limit and offset manually via epilog() works, but than I'd have to recreate the whole pagination mechanism in my code. While this is my current plan in case I can't find a better solution, I don't believe this would be the right way to do it.
Could someone (#PhantomWatson, #ndm) show an example, how the suggested custom finder can solve this?
How do I get only a row which matches my query: ?q=taxonomy_ids:1/636/*
Got that result:
Want only: <str>1/636/587</str>
There is no easy way. However, there is a trick, where you use a match highlighter and use those results instead of the results returned from the search itself. You may want to configure PRE/POST highlight tags to empty strings. There was an article on the web about somewhere, but I can't find it again.
The disadvantage is that you get your results twice. Once as docs and once as highlight.
The other option is a custom component that hooks into Lucene's explain structure.
I need (for a real good reason, trust me) to load what's almost the entire graph of my database using NHibernate. There are not so many entities, but the graph is kind of convoluted.
My graph looks something like :
EntityA
|
--> EntityB
|
--> List
|
--> EntityD
|
--> List
|
--> EntityF
Well... You get the idea.
I would like to load all of it with as few queries and roundtrips as possible, and possibly no select N+1 at all. Also I want to keep it as a graph, so I can easily loop through it later.
What's my best option? NHibernateUtil.Initialize()? Fetch()/FetchMany()? Future/MultiQuery?
I'm kind of lost, but I guess I'll have to do it in multiple operations. But what would the most efficient?
And bonus : all the entities have a IsPublished property. I want to be able to load either all the entities or only those that are published.
EDIT
In the end I tried this :
var applicationFields = NHibernateSession.Current.Query<ApplicationField>().Where(af => af.Ispublished)
.FetchMany(af => af.Illustrations)
.ThenFetch(i => i.InteractiveConfiguration)
.ThenFetchMany(ic => ic.UniqueSellingPoints)
.ThenFetchMany(usp => usp.Pictures)
.ToList();
Considering the way my graph looks, I think it's quite OK. Also I don't have multiple collections on same level, which is what induce cartesian products as far as I know.
For those who asked, it's not a recursion problem. Otherwise I would be using SQL Server CTE. Also I'm not updating any entity; it's just plain read (for an offline app).
But I'm clueless for my "bonus" question. I know EF can load partial collections based on filters, but it doesn't seem possible with NH.
short answer: a combination of Fetch()/FetchMany() and Future() depending on the usecase and expected list-sizes