minimum_should_match parameter in Azure Search - azure-cognitive-search

We would like to find an alternative of Elasticsearch: minimum_should_match in Azure Search
Elasticsearch query example:
"bool" : {
"must" : [
{
"bool" : {
"should" : [{...}],
"adjust_pure_negative" : true,
"minimum_should_match" : "45",
"boost" : 1.0
}
},
{
"bool" : {
"should" : [{...}],
"adjust_pure_negative" : true,
"minimum_should_match" : "38",
"boost" : 1.0
}
},
{
"bool" : {
"should" : [{...}],
"adjust_pure_negative" : true,
"minimum_should_match" : "29",
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
We successfully transformed ES query to Azure Search one, except for minimum_should_match parameter. Any suggestions?

Unfortunately, Azure Cognitive Search does not currently expose Elasticsearch's minimum_should_match to the user, and it is not being worked on right now. If there is enough customer demand down the line, we will add it to our roadmap.

Related

Problems with JSON

I'm trying to Order in ascending order the requirements that are not between 25,000 and 30,000. The requirements are information of an array which is inside of a document and the condition is that they can't be in that determined range. I'm trying to do it properly but i can't find any information about this.
Document structure
{
"_id" : ObjectId("5ec73abebd7e4d618a05734e"),
"code" : "A47",
"title" : "Software engineer",
"description" : "Analyze, design, create, test computer and software systems.",
"city" : "Madrid",
"date" : ISODate("2020-05-22T02:36:46.271Z"),
"salary" : 30000.0,
"active" : true,
"requirements" : [
"python",
"java",
"html5",
"C++",
"C#"
],
"info_company" : {
"cif" : "A00000000",
"name" : "FUTURE S.A",
"location" : "Madrid",
"web" : "www.future.es",
"about" : "We are a leading company in new technologies."
},
"pyme" : true
}
db.offers.update(
{ $ne : [ salary: {
$gte : 25000,
$lte : 35000 ]
} },
{
$push : {
requirements: {
$each : [] ,
$sort : 1
}
}
}
,
{
multi : true
} )

MongoDB query to retrieve a specific value from the document located in a array

I am trying to make a request in a document with mongodb.
In this document
{
"_id" : ObjectId("5bd19a92da24674fdabd26b6"),
"search" : "try",
"name" : "try",
"email" : "yes#gmail.com",
"password" : "$2a$10$YIRuApqDy/L8HU7R1k2SB.aC2hqH8xFDbl3/muF7PsoN6/SGzsH4q",
"color" : 0,
"profil" : "",
"banner" : "",
"desc" : "",
"date" : 45587899,
"friend" : [
{
"id" : ObjectId("5bcee588ae409f434d35c76c")
}
],
"groupes" : [ ]
}
I'm looking to get just the id in friend, not all of the document just 1 id in friend with where i try this :
db.users.find({$and:[{"friend.id":"ObjectId(5bcee588ae409f434d35c76c)"},{"search":"try"}]})
It's not working i got no result.
Thank you for helping me.
I am not 100% sure I do understand your question properly. You should be able to query the described document via the following query:
find(
/* query by 'search' and the specific friend-id */
{'friend.id': ObjectId("5bcee588ae409f434d35c76c"), search: 'try'},
/* return only that 'friend' element which matches the queried 'friend-id' */
{_id:0, friend:{$elemMatch:{id:ObjectId("5bcee588ae409f434d35c76c")}}}
)
You get the following result:
{
"friend" : [
{
"id" : ObjectId("5bcee588ae409f434d35c76c")
}
]
}
db.users.find({
friend: {
$elemMatch: {
id: ObjectId("5bcee588ae409f434d35c76c")
}
},
search: 'try'
})

It is possible to automatically delete data older than for instance 10 days from elasticsearch in real-time?

curl -XGET '127.0.0.1:9200/messages/message/_search?pretty' returns data like shown below. I wonder whether it is possible to automatically delete data older than for instance 10 days from elasticsearch preferably in real time? I added my example data because there is a field date that could be used in this case. Or maybe there is a different more recommended method?
{
"took" : 22,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [
{
"_index" : "messages",
"_type" : "message",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"message" : "example message1"
}
},
{
"_index" : "messages",
"_type" : "message",
"_id" : "ZODslt0LZ1T6GMrC",
"_score" : 1.0,
"_source" : {
"date" : "2018-05-25T10:06:06Z",
"message" : "example message1"
}
}
]
}
}
Elastic Curator is exactly what you are looking for. You should create a separate file for an index for each day.
For example if your index has pattern like that: YOUR_INDEX_NAME-%{+YYYY.MM.dd} then you should apply configuration below:
actions:
1:
action: delete_indices
options:
ignore_empty_list: True
timeout_override:
continue_if_exception: False
disable_action: False
filters:
- filtertype: pattern
kind: prefix
value: YOUR_INDEX_NAME-
exclude:
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d' <--- date pattern in your index name
unit: days
unit_count: 10 <--- after how many days delete the index

facets in elastic 5.5

I'm trying to build a feceted search with elastic 5.5 (With elastic 2.* I found information on how to do this but in 5.5 I can't)
Not something unusual, store-like items that i want to show hint of the amount if the user will choose to filter using some property. Image for visualisation
Data set example:
[
{
"id" : "978-0641723445",
"cat" : ["book","hardcover"],
"name" : "The Lightning Thief",
"author" : "Rick Riordan",
"series_t" : "Percy Jackson and the Olympians",
"sequence_i" : 1,
"genre_s" : "fantasy",
"inStock" : true,
"price" : 12.50,
"pages_i" : 384
}
,
{
"id" : "978-1423103349",
"cat" : ["book","paperback"],
"name" : "The Sea of Monsters",
"author" : "Rick Riordan",
"series_t" : "Percy Jackson and the Olympians",
"sequence_i" : 2,
"genre_s" : "fantasy",
"inStock" : true,
"price" : 6.49,
"pages_i" : 304
}
,
{
"id" : "978-1857995879",
"cat" : ["book","paperback"],
"name" : "Sophie's World : The Greek Philosophers",
"author" : "Jostein Gaarder",
"sequence_i" : 1,
"genre_s" : "fantasy",
"inStock" : true,
"price" : 3.07,
"pages_i" : 64
}
,
{
"id" : "978-1933988177",
"cat" : ["book","paperback"],
"name" : "Lucene in Action, Second Edition",
"author" : "Michael McCandless",
"sequence_i" : 1,
"genre_s" : "IT",
"inStock" : true,
"price" : 30.50,
"pages_i" : 475
}
]
Thanks!
You just have to use aggs instead of facets. Aggregations are much more powerful than facets.
For example:
GET index/_search
{
"aggs" : {
"countries" : {
"terms" : { "field" : "country" }
},
"types" : {
"terms" : { "field" : "type" }
}
}
}
Then if a user click on a "facet", just add a filter clause within a bool query (this will update all facet counts) or add a post_filter to just filter the results (does not affect aggregations).
if the column is text, you will need to use ".keyword" too to handle cases of country names where there are many words ("El Salvador", "United States of America", etc)
GET index/_search
{
"aggs" : {
"countries" : {
"terms" : { "field" : "country.keyword" }
}
}
}

Why is my API not showing up on deployment?

I suspect this is caused by the following bug in Endpoints (if valid) but I'm also sure there's a workaround somewhere.
https://code.google.com/p/googleappengine/issues/detail?id=9050&can=4&colspec=ID%20Type%20Component%20Status%20Stars%20Summary%20Language%20Priority%20Owner%20Log
Steps to reproduce:
Change a method name, API name of a method, or parameter list in an Endpoints class.
Run the endpoints.sh script to generate the API files.
Inspect the API files locally and witness the changes being there. So far so good.
Deploy to the default version of the app on the server.
Check the logs for the call to /_ah/spi/BackendService.getApiConfigs. There are no errors!
Go to API Explorer and clear the browser cache. Inspect the API. The change is not there.
Request the API file directly in the browser, eg. https://[app-id].appspot.com/_ah/api/discovery/v1/apis/[api-name]/v1/rpc The change is not there.
Frustrated with the above, I decided to start completely from scratch on a new app ID. I still see no API in the API Explorer and get a 404 on the URL in step 7 above!
Here's my endpoint class:
#Api(name = "ditto", version = "v1")
public class CategoryEndpoint extends BaseEndpoint {
#SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(CategoryEndpoint.class.getName());
#ApiMethod(name = "category.list")
public WireCategory list() {
Category root = categoryDao.getRoot();
WireCategory wireRootCategory = new WireCategory(root);
return wireRootCategory;
}
}
And here's the generated .api file:
{
"extends" : "thirdParty.api",
"abstract" : false,
"root" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/api",
"name" : "ditto",
"version" : "v1",
"defaultVersion" : false,
"adapter" : {
"bns" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/spi",
"deadline" : 10.0,
"type" : "lily"
},
"auth" : {
"allowCookieAuth" : false
},
"frontendLimits" : {
"unregisteredUserQps" : -1,
"unregisteredQps" : -1,
"unregisteredDaily" : -1,
"rules" : [ ]
},
"cacheControl" : {
"type" : "no-cache",
"maxAge" : 0
},
"methods" : {
"ditto.category.list" : {
"path" : "list",
"httpMethod" : "GET",
"scopes" : [ ],
"audiences" : [ ],
"clientIds" : [ ],
"rosyMethod" : "ditto.api.CategoryEndpoint.list",
"request" : {
"body" : "empty"
},
"response" : {
"body" : "autoTemplate(backendResponse)"
}
}
},
"descriptor" : {
"schemas" : {
"WireCategory" : {
"id" : "WireCategory",
"type" : "object",
"properties" : {
"webSafePath" : {
"type" : "string"
},
"prettyPath" : {
"type" : "string"
},
"children" : {
"type" : "array",
"items" : {
"$ref" : "WireCategory"
}
},
"path" : {
"type" : "array",
"items" : {
"type" : "string"
}
},
"name" : {
"type" : "string"
},
"id" : {
"type" : "string",
"format" : "int64"
}
}
}
},
"methods" : {
"ditto.api.CategoryEndpoint.list" : {
"response" : {
"$ref" : "WireCategory"
}
}
}
}
}
This URL gives me a 404 where I expect to see my API JSON:
https://eliot-dev-uk-ditto-do.appspot.com/_ah/api/discovery/v1/apis/ditto/v1
This is killing me!
EDIT:
Here's a diff I just spotted between the .api file generated by App Engine 1.7.5 and 1.7.6. Not sure why the URLs have changed.
ditto-v1.api from 1.7.6:
{
"extends" : "thirdParty.api",
"abstract" : false,
"root" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/api",
"name" : "ditto",
"version" : "v1",
"defaultVersion" : false,
"adapter" : {
"bns" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/spi",
"deadline" : 10.0,
"type" : "lily"
}
...
ditto-v1.api from 1.7.5:
{
"extends" : "thirdParty.api",
"abstract" : false,
"root" : "https://eliot-dev-uk-ditto-do.appspot.com/_ah/api",
"name" : "ditto",
"version" : "v1",
"defaultVersion" : false,
"adapter" : {
"bns" : "http://eliot-dev-uk-ditto-do.appspot.com/_ah/spi",
"deadline" : 10.0,
"type" : "lily"
}
...
As you already pointed out, it was due to an weird issue in SDK 1.7.6, which adds that 1. at the beginning of the endpoint root url in the .api files...
I've tried the new SDK 1.7.7 and it seems to be solved...

Resources