2016年4月月 发布的文章

程序员如何写技术文章

程序员如何写技术文章
看了一下知乎的文章总结下:
1、花时间
2、坚持
3、注意写作的方法和技巧
4、给别人讲授和分享
5、通过流量等方式,获取成就感,增加写作动力
https://www.zhihu.com/question/40716838
https://www.zhihu.com/question/39212891

elasticsearch在window下的安装和java查询

下载elasticsearch的zip包,elasticsearch的版本是2.2.1
ps:elasticsearch的api随版本更新的速度快,这里边需要查看对应版本的api文档
解压后安装,elasticsearch的访问地址:
http://localhost:9200/

{
  "name" : "Venus",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "2.2.1",
    "build_hash" : "d045fc29d1932bce18b2e65ab8b297fbf6cd41a1",
    "build_timestamp" : "2016-03-09T09:38:54Z",
    "build_snapshot" : false,
    "lucene_version" : "5.4.1"
  },
  "tagline" : "You Know, for Search"
}

安装插件:
elasticsearch插件elasticsearch-head安装:
elasticsearch-head是一个elasticsearch的集群管理工具,它是完全由html5编写的独立网页程序,你可以通过插件把它集成到es。
在cmd进入elasticsearch安装的bin目录,执行下边的命令:

plugin install mobz/elasticsearch-head

网上查的命令是:

plugin -install mobz/elasticsearch-head

注意比较不同
安装完命令可以打开url:http://localhost:9200/_plugin/head/ 查看效果

elasticsearch-head

elasticsearch-head


bigdesk这个插件就不要安装了,github上的代码都是几年前的了
pojo类:

package com.rong360.elasticsearch;
public class User {
	private long id;
	private String name;
	private int age;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
}

elasticsearch建立索引:

package com.rong360.elasticsearch;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHits;
public class ElasticSearchClient {
	private static Client client;
	public void init() {
		try {
			client = TransportClient.builder().build()
					.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
	}
	public void close() {
		client.close();
	}
	public void createIndex() {
		for (int i = 0; i < 1000; i++) {
			User user = new User();
			user.setId(new Long(i));
			user.setName("huang fox " + i);
			user.setAge(i % 100);
			client.prepareIndex("users", "user").setSource(generateJson(user)).execute().actionGet();
		}
	}
	private String generateJson(User user) {
		String json = "";
		try {
			XContentBuilder contentBuilder = XContentFactory.jsonBuilder().startObject();
			contentBuilder.field("id", user.getId() + "");
			contentBuilder.field("name", user.getName());
			contentBuilder.field("age", user.getAge() + "");
			json = contentBuilder.endObject().string();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return json;
	}
	public static void search() {
		SearchResponse response = client.prepareSearch("users").setTypes("user")
				.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
				.setQuery(QueryBuilders.termQuery("name", "fox")) // Query
				.setPostFilter(QueryBuilders.rangeQuery("age").from(22).to(26))// Filter
				.setFrom(0).setSize(60).setExplain(true).execute().actionGet();
		SearchHits hits = response.getHits();
		System.out.println(hits.getTotalHits());
		for (int i = 0; i < hits.getHits().length; i++) {
			System.out.println(hits.getHits()[i].getSourceAsString());
		}
	}
	public static void main(String[] args) {
		long a = System.currentTimeMillis();
		ElasticSearchClient elasticSearchClient = new ElasticSearchClient();
		elasticSearchClient.init();
		System.out.println("监测的时间1:"+(System.currentTimeMillis()-a)/1000f+" 秒 ");
		elasticSearchClient.createIndex();	//创建索引
		System.out.println("监测的时间2:"+(System.currentTimeMillis()-a)/1000f+" 秒 ");
		search();	//查询
		System.out.println("监测的时间3:"+(System.currentTimeMillis()-a)/1000f+" 秒 ");
		elasticSearchClient.close();
	}
}
elasticsearch_demo

elasticsearch_demo

知乎上关于融360的信息

所以融360的商业模式有以下几块,
单纯作为向银行倒入客户的入口,收取介绍费
如果推荐客户获贷,收取佣金
与银行合作,将其产品在自家网站上布点,收取广告费
融360目前有三种盈利模式:

  1. 向金融机构推荐贷款客户收取介绍费。目前在总体营收中的占比约80%。
  2. 佣金。通过撮合复杂需求用户与金融机构之间的交易,贷款获批后,融360收取贷款额的一定百分比作为返佣。目前,来自这部分的营收在整体营收中占比在15%左右。
  3. 在线广告。目前占比在5%左右。
融360可以继续发挥融资贷款科普教育,共同传递信贷文化中的正能量
客户和融360平台之间的黏性肯定不如客户和已经成交一次的业务员之间的黏性。
融360的目前获客成本过高
目前看来懂金融的不懂互联网,懂互联网的不懂金融,进入金融互联网,我认为门槛会较高,它应该不是搜索,而是增值服务,因此融360要是成为“去哪儿”,那么它不会有太大价值,要是成为“穷游”,那价值是非常大的。
社交类金融信息服务平台感觉上更有前途一些,但是需要更好的抓手。
当然投入和产出成比,因为看出来风险小所以融360的商业模式决定了它更像去哪儿,更像团800。现在市场快速发展期间比较好,当然市场稳固后,每个分类只省了几家后,它们就更愿意从最上流直接引流。再加上借款这事频次很低,优质的房贷和车贷融360又无法参与。这样优质的借款人资源更多是直接从银行处借贷[是融360看一下借款的利息就知道他们的主要服务的人群了]。所以融360的商业模式决定了,他就要不断买流量[批发]再不断导入到银行和小贷机构[零售],说什么大数据数据都需要自己从外部采样再清洗难度何其大。