我试图在SQL中找到等效于IN
\的ElasticSearch查询NOT
.
我知道我们可以使用带有多个OR的QueryString查询来获得相同的答案,但最终会有大量的OR.
有人可以分享这个例子吗?
当我使用brew
它安装elasticsearch时,自动默认为版本0.90.5
.有没有办法告诉brew安装版本1.1
?
string aux;
int maxy,auxx=0;
cin>>aux;
maxy= (int)sqrt(aux.size());
Run Code Online (Sandbox Code Playgroud)
我在说:
1> error C2668: 'sqrt' : ambiguous call to overloaded function
1> could be 'long double sqrt(long double)'
1> or 'float sqrt(float)'
1> or 'double sqrt(double)'
Run Code Online (Sandbox Code Playgroud)
为什么?
我已经为索引中的tweetb
类型创建了一个映射twitter
:
curl -XPUT http://www.mydomain:9200/twitter/tweetb/_mapping -d '{
"twitter": {
"mappings": {
"tweetb": {
"properties": {
"message": {
"type": "string",
"null_value": "NA"
}
}
}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
然后,我把一个文件:
curl -XPUT http://www.mydomain.com:9200/twitter/tweetb/1 -d '{"message": null}'
Run Code Online (Sandbox Code Playgroud)
然后,我试图让插入的doc回来:
curl -XGET http://www.mydomain:9200/twitter/tweetb/1
Run Code Online (Sandbox Code Playgroud)
那回来了:
{
"_index": "twitter",
"_type": "tweetb",
"_id": "1",
"_version": 2,
"found" : true,
"_source" : { "message": null }
}
Run Code Online (Sandbox Code Playgroud)
我"message" : "NA"
在_source
田野里期待着.但是,它似乎"null_value"
不起作用.我错过了什么吗?
我有一个奇怪的问题:
在我的C#app中,我正在创建另一个线程,如下所示:
Thread printThread = new Thread(printWorker);
printThread.Name = "Logger MainThread";
printThread.IsBackground = true;
printThread.Start();
Run Code Online (Sandbox Code Playgroud)
当我的主线程完成时,这个新线程继续工作,虽然它被标记为背景.
可能是什么原因造成的?这个对象持有Mutex对象,不确定这可能是原因......
任何人的想法?
这是printWorker方法的代码:
while (loggerIsActive)
{
LogMessage log = LoggerQueue.Dequeue();
if (log.message != null)
{
syncLogObj.WaitOne();
lock (writerobj)
{
StreamWriter sw;
if (!File.Exists(fName))
{
sw = File.CreateText(fName);
}
else
{
sw = new StreamWriter(fName, true);
}
using (sw)
{
if (log.message != "")
{
if (log.message.EndsWith("\r\n"))
{
log.message =
log.message.Substring(0, log.message.Length - 2);
}
sw.WriteLine(string.Format("[{0}][{3}][{1}] | {2}",
log.msgTime,
log.level.ToString(),
log.message,
log.sender.ToString()));
}
sw.Flush();
sw.Close(); …
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试InjectableProvider
用泽西岛创造一个,但我不能让泽西拿起它.
我找不到它的用法的任何真实例子,甚至除了@Provider
在实现上使用注释之外如何获取它.看似在泽西岛内写作的人在某些帖子中暗示这足以让它捡起来.
我是否需要指定一些SPI服务文件,或者将其添加到某个工厂?
注意:我在Glassfish 3.1中运行,并使用Spring 3.1.Spring可能以某种方式接管自动加载Provider
s 似乎是合理的.但是,我只是不知道.我不是在使用Spring来管理下面建议的InjectableProvider,也不是我试图以其他方式添加它,这可能是我的问题.
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider;
public abstract class AbstractAttributeInjectableProvider<T>
extends PerRequestTypeInjectableProvider<AttributeParam, T>
{
protected final Class<T> type;
public AbstractAttributeInjectableProvider(Class<T> type)
{
super(type);
this.type = type;
}
@Override
public Injectable<T> getInjectable(ComponentContext componentContext,
AttributeParam attributeParam)
{
return new AttributeInjectable<T>(type, attributeParam.value());
}
}
Run Code Online (Sandbox Code Playgroud)
基本实施:
import javax.ws.rs.ext.Provider;
@Component // <- Spring Annotation
@Provider // <- Jersey Annotation
public class MyTypeAttributeInjectableProvider
extends AbstractAttributeInjectableProvider<MyType>
{
public MyTypeAttributeInjectableProvider()
{
super(MyType.class);
}
}
Run Code Online (Sandbox Code Playgroud)
参考 …
我在C中编写了一个等待事件的程序,然后按system()
功能运行外部系统命令.
while( true ){
wait_for_event();
system("cmd");
}
Run Code Online (Sandbox Code Playgroud)
我有一个严重的问题,这cmd
是一个繁重的命令,需要几秒钟才能完成,我的应用程序在这段时间内错过了一些事件.
所以我决定把这个system
非常重的函数移到另一个程序中,所以我改变了我的程序如下:
while( true ){
wait_for_event();
write_to_fifo("cmd");
}
Run Code Online (Sandbox Code Playgroud)
并写了另一个程序:
while(true){
system(read_from_pipe());
}
Run Code Online (Sandbox Code Playgroud)
但它没有帮助,因为如果生产者(第一个程序)的写入速度比消费者(第二个程序)快,那么消费者会错过一些数据!
有没有办法解决这个问题?
我试图以JToggleButton
可靠,外观和感觉独立的方式改变它的颜色.
如果使用Metal L&F,那么使用UIManager是一种方法:
UIManager.put("ToggleButton.selected", Color.RED);
Run Code Online (Sandbox Code Playgroud)
注意:Iyy指出我上面的属性名称中有一个拼写错误,但我会将其留在上面,以便人们到达这里,但实际的属性名称应该是:
UIManager.put("ToggleButton.select", Color.RED);
Run Code Online (Sandbox Code Playgroud)
但是,这在我目前的外观(目前是Windows XP)中不起作用.经过一些进一步的分析,似乎Windows中的系统外观(仍然是XP)根本不使用任何Color
基于UIManager
属性的属性ToggleButton
,或者它至少不提供它们本身(有一个在线快速查找的UIManager
例子)来自的所有属性键,在示例中明确地明确限制Color
属性).
我试过设置背景颜色:
Action action = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) { /* stuff */ }
};
JToggleButton button = new JToggleButton(action);
// tried with and without opaque true
button.setOpaque(true);
button.setBackground(Color.RED);
Run Code Online (Sandbox Code Playgroud)
它不仅不会改变选定的状态,而且甚至不会影响未选择的状态.
我在尝试接收动作后尝试更改背景颜色:
@Override
public void actionPerformed(ActionEvent e)
{
JToggleButton button = (JToggleButton)e.getSource();
if (button.isSelected()) // alternatively, (Boolean)getValue(Action.SELECTED_KEY)
{
button.setBackground(Color.RED);
}
}
Run Code Online (Sandbox Code Playgroud)
这些都不起作用.我发现工作的唯一要求是我自己在选定状态下绘制按钮(这导致一个工作示例,虽然看起来非标准): …
我定义了以下滚动索引:
POST /_aliases
{
"actions": [
{
"add": {
"index": "elmah_*",
"alias": "elmah_all"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
今天效果很好,它收集了我所有现有的每月滚动索引。问题是,当索引滚动到新的月份时,它会自动生成 的新索引elmah_2016_06
,但是我的别名没有选择这个新索引。每个月我都需要通过运行以下命令来更新我的别名:
POST /_aliases
{
"actions": [
{
"add": {
"index": "elmah_2016-06",
"alias": "elmah_all"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
有没有办法让 ES 自动选择它?
我有一个Response.Redirect
在我的Page_Load
:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
...Code
Response.Redirect("http://www.mysite.com")
End Sub
Run Code Online (Sandbox Code Playgroud)
在添加Response.Redirect之前,我有其他子例程和工作代码
当Response.Redirect
加入他们都不会处理自己的代码,并自动执行该Response.Redirect
网站.
当没有时,我的代码可以正常工作Response.Redirect
.