我希望用户能够轻松找到一个系列,所以想要设置方面.我已按照seachkick的指示进行操作,一切正常,但是当我设置Facets时,我得到以下作为返回.我想让它像他们的文档一样.希望有人能提供帮助.
我在myapp.com/movies中得到这个
{
"name"=> {
"_type"=> "terms",
"missing"=> 0,
"total"=> 1,
"other"=> 0,
"terms"=> [
{
"term"=> "Bloop",
"count"=> 1
}
]
},
"imdb"=> {
"_type"=> "terms",
"missing"=> 0,
"total"=> 1,
"other"=> 0,
"terms"=> [
{
"term" => "http://www.bloop.com",
"count" => 1
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
#app/views/movies/index.html.erb
<%= p @series.facets %>
Run Code Online (Sandbox Code Playgroud)
#app/controllers/movies_controller.rb
def index
query = params[:query].presence || "*"
@movies = Movie.search(query, page: params[:page],
suggest: true,
per_page: 20,
facets: [:name, :imdb])
end
Run Code Online (Sandbox Code Playgroud)
#db/schema.rb
create_table "movies", force: …Run Code Online (Sandbox Code Playgroud) curl localhost:9200/tweet/posts/_search -d '{
"query": {
"and": [
{
"wildcard": {
"_all": "*pet*"
}
},
{
"wildcard": {
"_all": "*rom*"
}
}
]
}
}'
Run Code Online (Sandbox Code Playgroud)
这给了我一个解析异常.我想运行like(%test%)带有AND条件的MySQL 类型查询.在弹性搜索中还有其他好的方法吗?
我是Elasticsearch的新手.我有一个映射,其中包含以下字段:
{
"book": {
"book": {
"dynamic": "false",
"_source": {
"enabled": true
},
"_id": {
"path": "id"
},
"properties": {
"id": {
"type": "long",
"store": "yes",
"index": "not_analyzed",
"include_in_all": false
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我能够创建索引并添加文档.但是,当我运行查询时,例如:
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"ids": {
"type": "long",
"values" : [10]
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
它什么都不返回(索引有一个id = 10的文档).我对此链接感到困惑:
任何人都可以启发我吗?我做错了什么?
我想问一下唯一字段_id是否由文档中的某个字段分配。我看到 Rest,它可以通过path以下方式实现:
{
"tweet": {
"_id": {
"path": "post_id"
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是如果我想用java API来做,有什么办法可以实现吗?
Map<String, Object> MapA= new HashMap<String, Object>();
MapA=MapProcessor(MapA);
client.prepareIndex("index","type").setSource(MapA).execute().actionGet();
Run Code Online (Sandbox Code Playgroud)
如何修改我的代码以分配 Map 中的某些字段成为_id这种类型?
我对ElasticSearch聚合很新.我希望能够计算使用非空字段检索的文档数.
这是我用来计算有多少文档没有name字段的方法.
{
"size": 3,
"query": {
"query_string": {
"query": "martin"
}
},
"aggs": {
"results_without_mb_id": {
"missing": {
"field": "name"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
它有效,但我想做的恰恰相反.有existing汇总吗?
我正在尝试使用 Next.js 在 Keycloak 中进行身份验证@react-keycloak/nextjs,但是一旦我通过登录,它就会不断地将我发送回 Keycloak 服务器并返回主页,直到它给我一个错误,因为我的令牌密钥已过期。这是我的_app.js:
import { ApolloProvider } from '@apollo/react-hooks'
import CssBaseline from '@material-ui/core/CssBaseline'
import { ThemeProvider } from '@material-ui/core/styles'
import { Persistors, SSRKeycloakProvider } from '@react-keycloak/nextjs'
import Layout from 'components/layout/Layout'
import { useApollo } from 'lib/apolloClient'
import KeycloakLoading from 'components/KeycloakLoading'
import {
keycloakCfg,
keycloakProviderInitConfig,
onKeycloakLogout,
onKeycloakTokens,
} from 'lib/keycloak'
import Head from 'next/head'
import PropTypes from 'prop-types'
import React from 'react'
import theme from 'styles/theme'
import 'leaflet/dist/leaflet.css'
import 'react-leaflet-markercluster/dist/styles.min.css'
import 'styles/styles.css'
import …Run Code Online (Sandbox Code Playgroud) 我对Elasticsearch很新.我正在尝试编写一个将按字段分组并计算总和的查询.在SQL中,我的查询看起来像这样:
SELECT lane, SUM(routes) FROM lanes GROUP BY lane
我在ES中看到这样的数据:
{
"_index": "kpi",
"_type": "mroutes_by_lane",
"_id": "TUeWFEhnS9q1Ukb2QdZABg",
"_score": 1.0,
"_source": {
"warehouse_id": 107,
"date": "2013-04-08",
"lane": "M05",
"routes": 4047
}
},
{
"_index": "kpi",
"_type": "mroutes_by_lane",
"_id": "owVmGW9GT562_2Alfru2DA",
"_score": 1.0,
"_source": {
"warehouse_id": 107,
"date": "2013-04-08",
"lane": "M03",
"routes": 4065
}
},
{
"_index": "kpi",
"_type": "mroutes_by_lane",
"_id": "JY9xNDxqSsajw76oMC2gxA",
"_score": 1.0,
"_source": {
"warehouse_id": 107,
"date": "2013-04-08",
"lane": "M05",
"routes": 3056
}
},
{
"_index": "kpi",
"_type": "mroutes_by_lane",
"_id": "owVmGW9GT345_2Alfru2DB", …Run Code Online (Sandbox Code Playgroud) 我看到有关弹性搜索1.2.0(最近从1.0.1升级)的ID的奇怪行为.
搜索检索我的文档,显示_id的正确值:
[终奌站]
curl 'myServer:9200/global/_search?q=someField:something
Run Code Online (Sandbox Code Playgroud)
结果是
{
"took": 79,
"timed_out": false,
"_shards": {
"total": 12,
"successful": 12,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 17.715034,
"hits": [
{
"_index": "global",
"_type": "user",
"_id": "7a113e4f-44de-3b2b-a3f1-fb881da1b00a",
...
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
但直接查找id不会:
[terminal]
curl 'myServer:9200/global/user/7a113e4f-44de-3b2b-a3f1-fb881da1b00a'
Run Code Online (Sandbox Code Playgroud)
结果是
{
"_index": "global",
"_type": "user",
"_id": "7a113e4f-44de-3b2b-a3f1-fb881da1b00a",
"found": false
}
Run Code Online (Sandbox Code Playgroud)
这似乎是在以前使用自定义脚本更新的文档上.
有任何想法吗?
以前,我有这个:
{
query: {
function_score: {
filter: {
and: [
{
term: {
'currency': 'usd',
'_cache': false
}
}
]
},
script_score: {
"script": "_score * doc['random_score'].value"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
非常基本,我只是按货币过滤并按分数排序.
但自从我升级后,我无法获得任何简单的自定义分数查询.
我试图用这个例子来简化它:
{
query: {
function_score: {
script_score: {
"script": "_score * doc['random_score'].value"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我收到的错误如下:
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[PxzZtO8FQviuhxS-3EJFwA][listings][3]:
SearchParseException[[listings][3]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"function_score": {
"script_score": {
"script": "_score …Run Code Online (Sandbox Code Playgroud) 我在我的 react-native 项目(使用打字稿)中使用了 firebase,我正确设置了所有内容,并且可以正常处理data如下消息:
{
"to": "fcm-token",
"data": {
"field1": "value1",
"field2": "value1",
"field3": "value1"
}
}
Run Code Online (Sandbox Code Playgroud)
在我的应用程序,我可以访问我的数据使用data申请的RemoteMessage象下面这样:
const data: MyDataType = remoteMessage.data;
const {/* destructed fields */} = data;
Run Code Online (Sandbox Code Playgroud)
但当我的服务器将嵌套对象发送到 FCM 服务器时,它会将它们转换为字符串,因此我无法像上面那样直接访问它们。
这是我的服务器发送到 FCM 服务器的内容:
{
"to": "fcm-token",
"data": {
"field1": {
"subfield1": "subvalue1",
"subfield2": "subvalue2",
},
"field2": "value1",
"field3": "value1"
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我在我的应用程序中得到的:
{
"to": "fcm-token",
"data": {
"field1": "{"subfield1": "subvalue1","subfield2": "subvalue2"}", <--- the problem is here, it must be a …Run Code Online (Sandbox Code Playgroud) push-notification typescript react-native firebase-cloud-messaging react-native-firebase
aggregation ×1
curl ×1
keycloak ×1
lucene ×1
next.js ×1
nosql ×1
react-native ×1
reactjs ×1
ruby ×1
searchkick ×1
typescript ×1