简体   繁体   中英

I need to set-up elasticsearch on windows os?

I tried to set-up a elasticsearch on my Windows 7 OS PC. Installed elasticsearch and curl and it's working as the loacahost:9200 is working fine.

Now I am strugging to search in a file located at c:\\user\\rajesh\\raj.txt .

My doubt is, Where do mention that I have tos search in this file? elasticsearch.yml ? Which parameter I need to set to point this text file?

Indexing is working with curl but mapping gives nullpointer exception? Do I need to install something else?

I tried to install sense plugin for chrome but says moved to marvel, and from there unable to install marvel!

From what I can tell, you've installed Elasticsearch and you're now expecting to be able to search within files on your local file system. This isn't how ES works. You need to create a mapping for an index and then populate that index with the content you want to search in. If you're looking to index files on your local file system rather than data you have pulled from a database you should look in to the File system River Plugin for Elasticsearch, http://www.pilato.fr/fsriver/ . This deals with all of the indexing of file system based documents automatically, once you've got it set up correctly.

EDIT:

I also see you're trying to set up Kibana and Marvel/Sense. To set up Kibana just follow the instructions here: http://www.elasticsearch.org/overview/kibana/installation/

To set up Marvel open powershell, CD to C:\\elasticsearch\\bin then run plugin.bat -i elasticsearch/marvel/latest then you'll need to restart your cluster. Once you've done that if you go to http://localhost:9200/_plugin/marvel/ you'll see your marvel dashboard. You'll also see a tab for "Sense" which is the other plugin you referred to.

If you are using elastic search for retrieving data from any DB like PostgreSQL, then go to folder bin/rivers.bat and edit as

curl -XPUT localhost:9200/_river/actor_jdbc_river/_meta -d "{\"type\":\"jdbc\",\"jdbc\":{\"strategy\":\"simple\",\"poll\":\"1h\",\"driver\":\"org.postgresql.Driver\",\"url\":\"jdbc:postgresql://10.5.2.132:5432/prodDB\",\"user\":\"UserName\",\"password\":\"Password\",\"sql\":\"select t.id as _id,t.name from topic as t \",\"digesting\" : true},\"index\":{\"index\":\"jdbc\",\"type\":\"actor_jdbc_river1\"}}"

Then create a client in Java side to access data in river. Here cluster name is same as that mention in folder config/elasticsearch.yml (testDBsearch)

private static Client createClient() {
        //Create Client
        Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "testDBsearch").build();
        TransportClient transportClient = new TransportClient(settings);
        transportClient = transportClient.addTransportAddress(new InetSocketTransportAddress("10.5.2.132", 9300));
        return (Client) transportClient;

    }

public static void main(String[] args) {

            Client client = createClient();             
            String queryString = "python";
            search(client, 100, queryString);
        }

    public static  void search(Client client,int size, String queryString) {            
        queryString=queryString +"*";

        try{
            SearchResponse responseActor;
            responseActor = client.prepareSearch("jdbc").setTypes("actor_jdbc_river1").setSearchType(SearchType.DEFAULT)
                    .setQuery(QueryBuilders.queryString(queryString)
                            .field("designation",new Float(2.0)).field("name", new Float(5.0)).field("email")                                                   .defaultOperator(Operator.OR)).setFrom(0).setSize(size).setExplain(true).execute().actionGet();


        for(SearchHit hit:responseActor.getHits()) {                
            System.out.println(hit.getSourceAsString());
            System.out.println(hit.getScore());
            System.out.println("---------------------------");
        }

        }catch(Exception e){
            System.out.println("Error in elastic search "+queryString+"  Error :"+e);
        }

    }

clear installation of elasticsearch in windows:

1) check whether your system has latest java version

2) download and extract elasticsearch from "download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/zip/elasticsearch/2.3.3/elasticsearch-2.3.3.zip"

3) set JAVA_HOME environment variable "C:\\Program Files (x86)\\Java\\jdk1.8.0_91"

4) check JAVA_HOME environment variable using command "service" in bin directry of elasticsearch shown in below figure checking whether JAVA_HOME is set properly or not

5) install service.bat using command service.bat install

6) uncomment network.host and give value as localhost in configuration file of elasticsearch

        network.host= localhost in elasticsearch.yml (config file)

7)run elasticsearch "C:\\elasticsearch-2.3.3\\bin\\elasticsearch"

if you get error while running elastic search saying update JVM to latest version means java in your system is not containing latest version (install and run latest java version)

8)install elasticsearch-head plugin to visualize things in elasticsearch

run command "plugin install elasticsearch-head"

if its failed to install elasticsearch-head then use command-

plugin install "github.com/mobz/elasticsearch-head/archive/master.zip"

9)open elasticsearch in browser using link "localhost:9200/_plugin/head/"

elasticsearch visual interface

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM