我正在使用Java将数据插入到mongodb集群中.我可以拥有超过1个mongos实例,以便在我的一个mongos关闭时有备份吗?
这是我连接到mongos的java代码.
MongoClient mongoClient = new MongoClient("10.4.0.121",6001);
DB db = mongoClient.getDB("qbClientDB");
DBCollection collection = db.getCollection("clientInfo");
Run Code Online (Sandbox Code Playgroud)
如何在Java代码中指定我的第二个mongos实例?(如果可能的话).
提前致谢.
我有一个弹性搜索索引,用户的字段如..."name":"kai""age":"23""location":"Delhi,India""tag":["search","nosql"]等.
我想在用户的所有字段中查询多个字符串(例如.["nosql","delhi"]).是否可以使用Java API?
这是我正在使用的代码示例.(但这与问题无关)它只是为了知道我现在正在使用的对象.
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery()
.must(QueryBuilders.matchAllQuery());
if(location!=null) {
queryBuilder.must(QueryBuilders.matchQuery("location",location));
}
BoolFilterBuilder filerBuilder=FilterBuilders.boolFilter();
for(String skill:skills){
filerBuilder.must(FilterBuilders.rangeFilter("tags."+skill).from(0));
}
filerBuilder.must(FilterBuilders.queryFilter(queryBuilder));
if(age!=null) {
filerBuilder.must(FilterBuilders.rangeFilter("age").from(age[0]).to(age[1]));
}
SearchResponse response = client.prepareSearch("skillbin")
.setTypes("stackdump")
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(queryBuilder)
.setPostFilter(filerBuilder)
.addSort("reputation", SortOrder.DESC)
.execute()
.actionGet();
SearchHits hits=response.getHits();
Run Code Online (Sandbox Code Playgroud)
提前致谢.:)
我正在使用Selenium 2.x WebDriver来实现java项目的自动化.当自动化进行时,它到达一个页面,当点击提交按钮时,出现"弹出窗口"并且不能进行自动化.
码
public void writeSite(WebDriver driver, ZoneTest zone) throws BiffException, InterruptedException, IOException
//Creates a new zone for testing
General.elementClick_xpath(driver, Locators.siteMenuDropBoxXpath);
General.waitToLoad(General.WAIT_MIN);
General.elementClick_xpath(driver, Locators.viewSitesButtonXpath);
General.elementClick_xpath(driver, Locators.viewDataPointDetailsXpath);
General.waitToLoad(General.WAIT_AVG);
General.elementClick_xpath(driver, Locators.addZoneXpath);
General.waitToLoad(General.WAIT_AVG);
General.inputTextFieldEnter_Id(driver, "name", zone.zoneName);
General.inputTextFieldEnter_Id(driver, "description",zone.zoneDescription );
General.inputTextFieldEnter_Id(driver, "urlExtension", zone.urlExtension);
General.inputTextFieldEnter_Id(driver, "timeSpentThreshold", zone.thresholdTime);
General.inputTextFieldEnter_Id(driver, "tuningNumber", zone.tuningNumber);
**General.elementClick_xpath(driver, Locators.createZoneSubmitXpath);**
//Here a new pop up window apppears. And the following codes 3 lines doesnt work.
General.inputTextFieldEnter_Id(driver, "active", zone.act);
General.inputTextFieldEnter_Id(driver, "userid", zone.uid);
General.elementClick_xpath(driver, Locators.SubmitXpath)
}
public class General
{
public static final long …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Spring Social Facebook检索朋友的用户名.列出friends = facebook.friendOperations().getFriendProfiles(); 这句话给了我400 Bad Request错误.
@Controller
@RequestMapping("/")
public class HelloController {
private Facebook facebook;
@Inject
public HelloController(Facebook facebook) {
this.facebook = facebook;
}
@RequestMapping(method=RequestMethod.GET)
public String helloFacebook(Model model) {
if (!facebook.isAuthorized()) {
return "redirect:/connect/facebook";
}
model.addAttribute(facebook.userOperations().getUserProfile());
System.out.println(facebook.userOperations().getUserProfile().getName());
System.out.println(facebook.userOperations().getUserProfile().getEmail());
//PagedList<FacebookProfile> fbFrnds = facebook.friendOperations().getFriendProfiles();
List<String> friendIds = facebook.friendOperations().getFriendIds();
System.out.println("Id size : "+friendIds.size());
List<FacebookProfile> friends = facebook.friendOperations().getFriendProfiles();
System.out.println("Size : "+friends.size());
for (FacebookProfile id : friends) {
System.out.println(id.getName());
}
return "hello";
}
}
Run Code Online (Sandbox Code Playgroud)
错误如下所示.
2014-10-20 16:39:34.787 WARN 4648 --- [nio-8080-exec-6] o.s.web.client.RestTemplate …Run Code Online (Sandbox Code Playgroud)