我正在尝试从Java连接到ElasticSearch,但我只能通过HTTP连接.我不能用TransportClient.ElasticSearch REST API是否有Java客户端包装器?如果是这样,我该如何使用它?
我有几个json文档,格式如下: -
_source: {
userId: "A1A1",
customerId: "C1",
component: "comp_1",
timestamp: 1408986553,
}
Run Code Online (Sandbox Code Playgroud)
我想根据以下内容查询文档: -
(( userId == currentUserId) OR ( customerId== currentCustomerId) OR (currentRole ==ADMIN) ) AND component= currentComponent)
Run Code Online (Sandbox Code Playgroud)
我尝试使用SearchSourceBuilder和QueryBuilders.matchQuery,但我无法使用AND和OR运算符放置多个子查询.
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchQuery("userId",userId)).sort("timestamp", SortOrder.DESC).size(count);
Run Code Online (Sandbox Code Playgroud)
我们如何使用OR和AND运算符查询elasticsearch?
嗨当我使用jest客户端执行弹性搜索java API时,我面临以下错误
org.apache.http.client.ClientProtocolException:URI未指定有效的主机名:localhost:9200/index/type/_search
我尝试各种可能性来解决这个错误,但它不会有任何人指导我解决这个问题吗?.提前谢谢.
我正在尝试向受IAM访问策略保护的AWS Elasticsearch域发出HTTP请求.我需要签署这些请求,以便AWS授权这些请求.我正在使用Jest,后者又使用Apache HttpComponents Client.
这似乎是一个常见的用例,我想知道是否有某种类型的库,我可以在Apache HttpComponents客户端上使用它来签署所有请求.
java amazon-web-services elasticsearch apache-httpcomponents jest
我花了很长时间查看有关此问题的其他问题并查看Github上的其他项目,但似乎没有任何答案对我有用.
我正在我的项目中加载第三方库,当运行Jest测试时,我收到错误
export default portalCommunication;
^^^^^^
SyntaxError: Unexpected token export
> 1 | import portalCommunication from 'mathletics-portal-communication-service';
Run Code Online (Sandbox Code Playgroud)
我已尝试以多种方式更新我的Jest配置以使其转换此库但我总是得到相同的错误.
这是我当前的jest.config.js文件:
module.exports = {
moduleNameMapper: {
'\\.(css|scss)$': 'identity-obj-proxy',
'\\.svg$': '<rootDir>/test/mocks/svg-mock.js'
},
setupFiles: ['./test/test-setup.js'],
transformIgnorePatterns: [
'<rootDir>/node_modules/(?!mathletics-portal-communication-service)'
]
};
Run Code Online (Sandbox Code Playgroud)
我还尝试添加transform属性来对这个mathletics-portal-communication-service目录运行babel-jest.
请帮忙!
我在测试文件中得到了这些Flow错误:
identifier `test`
Could not resolve name
identifier `expect`
Could not resolve name
Run Code Online (Sandbox Code Playgroud)
我已经从flow-typed安装了Jest libdef,但它没有任何区别.
更新:看起来像flow-typed创建的Jest libdef只是一个存根.我认为问题是flow-typed还没有Jest v0.21.x的libdef.
我有一个带有对象的文件,其中包含process.env属性:
env.js
console.log('LOADING env.js');
const {
PROXY_PREFIX = '/api/',
USE_PROXY = 'true',
APP_PORT = '8080',
API_URL = 'https://api.address.com/',
NODE_ENV = 'production',
} = process.env;
const ENV = {
PROXY_PREFIX,
USE_PROXY,
APP_PORT,
API_URL,
NODE_ENV,
};
module.exports.ENV = ENV;
Run Code Online (Sandbox Code Playgroud)
现在我尝试使用不同的process.env属性测试此文件:
env.test.js
const envFilePath = '../../config/env';
describe('environmental variables', () => {
const OLD_ENV = process.env;
beforeEach(() => {
process.env = { ...OLD_ENV };
delete process.env.NODE_ENV;
});
afterEach(() => {
process.env = OLD_ENV;
});
test('have default values', () => { …Run Code Online (Sandbox Code Playgroud) 我有一个名为demo的索引,它包含不同的类型.我正在使用弹性搜索java内部api并在我的应用程序中休息api jest.基本上我想提出这个要求
curl -XGET 'http:localhost:9200/demo/_mapping'
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点,特别是在开玩笑api?有没有文档,以获取其他客户端API映射.你的建议是什么?
前段时间,亚马逊网络服务增加了选择ElasticSearch服务1.5或2.3版本的可能性.
我一直在使用旧版本,Jest客户端与AWS和内存中的ElasticSearch(单元测试)完美配合.当我更改依赖版本时,发生了一些错误.
当前版本:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>io.searchbox</groupId>
<artifactId>jest</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>vc.inreach.aws</groupId>
<artifactId>aws-signing-request-interceptor</artifactId>
<version>0.0.11</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我更新到:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.3.5</version>
</dependency>
<dependency>
<groupId>io.searchbox</groupId>
<artifactId>jest</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>vc.inreach.aws</groupId>
<artifactId>aws-signing-request-interceptor</artifactId>
<version>0.0.13</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我也可以在这里看到io.searchbox:jest-parent:2.0.3当前版本的ElasticSearch是2.1.0.
问题是,是否有机会实现Jest Client和AWS弹性搜索服务2.3版的兼容性?
当我运行我的代码时,我可以看到很多错误:
java.net.SocketTimeoutException:读取超时
几乎所有对ES的调用都引发了这种异常,只使用IndicesExists.Builder调用了正确返回的索引404.
ElasticSearch配置类:
public class ElasticSearchConfig {
private static final String ES_REGION = "us-east-1";
private static final String ES_SERVICE_PREFIX = "es";
@Bean
public JestClient jestClient(@Value("${es.endpoint}") String …Run Code Online (Sandbox Code Playgroud) 我有几个Redux-Thunk风格的函数,可以在一个文件中调度其他操作.其中一个动作将另一个作为其逻辑的一部分发送.它看起来类似于:
export const functionToMock = () => async (dispatch) => {
await dispatch({ type: 'a basic action' });
};
export const functionToTest = () => async (dispatch) => {
dispatch(functionToMock());
};
Run Code Online (Sandbox Code Playgroud)
在我实际遇到的情况下,函数更加复杂,并且每个函数都分派多个动作对象.结果,当我测试我的现实世界时functionToTest,我想模仿我的现实世界functionToMock.我们已经进行了functionToMock广泛的测试,我不想在这些测试中重复逻辑functionToTest.
但是,当我尝试这样的时候,就像这样:
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
jest.mock('../exampleActions');
const actions = require('../exampleActions');
const mockStore = configureMockStore([thunk]);
describe('example scenario showing my problem', () => {
test('functionToTest dispatches fuctionToMock', () => {
actions.functionToMock.mockReturnValue(() => Promise.resolve());
const store = mockStore({});
store.dispatch(actions.functionToTest()); …Run Code Online (Sandbox Code Playgroud) jest ×10
java ×5
javascript ×3
api ×1
babel-jest ×1
caching ×1
flow-typed ×1
flowtype ×1
mapping ×1
mocking ×1
node.js ×1
reactjs ×1
redux ×1
redux-thunk ×1
testing ×1