Elastic Go cannot find document
Sorry if this is a dumb question. I'm using a service which was built using Elasticsearch client for Go. I run the service and now seems like the elasticsearch server have the index of the data. However, when I tried to query those data with http://129.94.14.234:9200/chromosomes/chromosome/1
, I got {"_index":"chromosomes","_type":"chromosome","_id":"1","_version":1,"found":true,"_source":{"id":"1","length":249250621}}
I checked that the SQL query from the database have those data. Now the question is that, how do I check that my elasticsearch index have those data? Or If anyone can tell me what might be wrong on the code that'll be great as well.
Here's the code that I assume adding the documents to chromosomes
index.
func (c ChromosomeIndexer) AddDocuments(db *sql.DB, client *elastic.Client, coordID int) {
sqlQuery := fmt.Sprintf("SELECT seq_region.name, seq_region.length FROM seq_region WHERE seq_region.`name` REGEXP '^[[:digit:]]{1,2}$|^[xXyY]$|(?i)^mt$' AND seq_region.`coord_system_id` = %d", coordID)
stmtOut, err := db.Prepare(sqlQuery)
check(err)
defer stmtOut.Close()
stmtOut.Query()
rows, err := stmtOut.Query()
defer rows.Close()
check(err)
chromoFn := func(rows *sql.Rows, bulkRequest *elastic.BulkService) {
var name string
var length int
err = rows.Scan(&name, &length)
check(err)
chromo := Chromosome{ID: name, Length: length}
fmt.Printf("chromoID: %sn", chromo.ID)
req := elastic.NewBulkIndexRequest().
OpType("index").
Index("chromosomes").
Type("chromosome").
Id(chromo.ID).
Doc(chromo)
bulkRequest.Add(req)
}
elasticutil.IterateSQL(rows, client, chromoFn)
}
This service have other index which I can query the data with no problem, I only have problem when querying chromosomes
data.
Please let me know if I need to put more code so that I can give a bit more context on the problem, I just started on Go and Elasticsearch, and I tried reading the documentation, but it just leads to more confusion.
elasticsearch go
add a comment |
Sorry if this is a dumb question. I'm using a service which was built using Elasticsearch client for Go. I run the service and now seems like the elasticsearch server have the index of the data. However, when I tried to query those data with http://129.94.14.234:9200/chromosomes/chromosome/1
, I got {"_index":"chromosomes","_type":"chromosome","_id":"1","_version":1,"found":true,"_source":{"id":"1","length":249250621}}
I checked that the SQL query from the database have those data. Now the question is that, how do I check that my elasticsearch index have those data? Or If anyone can tell me what might be wrong on the code that'll be great as well.
Here's the code that I assume adding the documents to chromosomes
index.
func (c ChromosomeIndexer) AddDocuments(db *sql.DB, client *elastic.Client, coordID int) {
sqlQuery := fmt.Sprintf("SELECT seq_region.name, seq_region.length FROM seq_region WHERE seq_region.`name` REGEXP '^[[:digit:]]{1,2}$|^[xXyY]$|(?i)^mt$' AND seq_region.`coord_system_id` = %d", coordID)
stmtOut, err := db.Prepare(sqlQuery)
check(err)
defer stmtOut.Close()
stmtOut.Query()
rows, err := stmtOut.Query()
defer rows.Close()
check(err)
chromoFn := func(rows *sql.Rows, bulkRequest *elastic.BulkService) {
var name string
var length int
err = rows.Scan(&name, &length)
check(err)
chromo := Chromosome{ID: name, Length: length}
fmt.Printf("chromoID: %sn", chromo.ID)
req := elastic.NewBulkIndexRequest().
OpType("index").
Index("chromosomes").
Type("chromosome").
Id(chromo.ID).
Doc(chromo)
bulkRequest.Add(req)
}
elasticutil.IterateSQL(rows, client, chromoFn)
}
This service have other index which I can query the data with no problem, I only have problem when querying chromosomes
data.
Please let me know if I need to put more code so that I can give a bit more context on the problem, I just started on Go and Elasticsearch, and I tried reading the documentation, but it just leads to more confusion.
elasticsearch go
I got the service from here github.com/shusson/genesearch
– user3794740
Nov 15 '18 at 18:27
"I only have problem when querying chromosomes data". What problem? The code you show doesn't query ES at all. And in the very first paragraph you demonstrate that you can query the index successfully. It's really not clear what you're asking.
– Peter
Nov 15 '18 at 19:01
@Peter Sorry, if my question is not clear, as I'm still trying to understand ES and Go. So the piece of code that I attached there is for adding documents to thechromosomes
index that I have. I can query the index such that if I gohttp://129.94.14.234:9200/chromosomes/
I'll get the json file with the mappings of the chromosome, but what I want is the data on that index. If you're willing to see the repo of the service, it might give you better understanding of what I'm asking.
– user3794740
Nov 15 '18 at 19:15
129.94.14.234:9200/chromosomes/_search
– Peter
Nov 15 '18 at 21:00
@Peter I can see the data with/chromosomes/_search
, how do I get the data based on id? Also I'm still confused what's thetype
for?
– user3794740
Nov 15 '18 at 21:22
add a comment |
Sorry if this is a dumb question. I'm using a service which was built using Elasticsearch client for Go. I run the service and now seems like the elasticsearch server have the index of the data. However, when I tried to query those data with http://129.94.14.234:9200/chromosomes/chromosome/1
, I got {"_index":"chromosomes","_type":"chromosome","_id":"1","_version":1,"found":true,"_source":{"id":"1","length":249250621}}
I checked that the SQL query from the database have those data. Now the question is that, how do I check that my elasticsearch index have those data? Or If anyone can tell me what might be wrong on the code that'll be great as well.
Here's the code that I assume adding the documents to chromosomes
index.
func (c ChromosomeIndexer) AddDocuments(db *sql.DB, client *elastic.Client, coordID int) {
sqlQuery := fmt.Sprintf("SELECT seq_region.name, seq_region.length FROM seq_region WHERE seq_region.`name` REGEXP '^[[:digit:]]{1,2}$|^[xXyY]$|(?i)^mt$' AND seq_region.`coord_system_id` = %d", coordID)
stmtOut, err := db.Prepare(sqlQuery)
check(err)
defer stmtOut.Close()
stmtOut.Query()
rows, err := stmtOut.Query()
defer rows.Close()
check(err)
chromoFn := func(rows *sql.Rows, bulkRequest *elastic.BulkService) {
var name string
var length int
err = rows.Scan(&name, &length)
check(err)
chromo := Chromosome{ID: name, Length: length}
fmt.Printf("chromoID: %sn", chromo.ID)
req := elastic.NewBulkIndexRequest().
OpType("index").
Index("chromosomes").
Type("chromosome").
Id(chromo.ID).
Doc(chromo)
bulkRequest.Add(req)
}
elasticutil.IterateSQL(rows, client, chromoFn)
}
This service have other index which I can query the data with no problem, I only have problem when querying chromosomes
data.
Please let me know if I need to put more code so that I can give a bit more context on the problem, I just started on Go and Elasticsearch, and I tried reading the documentation, but it just leads to more confusion.
elasticsearch go
Sorry if this is a dumb question. I'm using a service which was built using Elasticsearch client for Go. I run the service and now seems like the elasticsearch server have the index of the data. However, when I tried to query those data with http://129.94.14.234:9200/chromosomes/chromosome/1
, I got {"_index":"chromosomes","_type":"chromosome","_id":"1","_version":1,"found":true,"_source":{"id":"1","length":249250621}}
I checked that the SQL query from the database have those data. Now the question is that, how do I check that my elasticsearch index have those data? Or If anyone can tell me what might be wrong on the code that'll be great as well.
Here's the code that I assume adding the documents to chromosomes
index.
func (c ChromosomeIndexer) AddDocuments(db *sql.DB, client *elastic.Client, coordID int) {
sqlQuery := fmt.Sprintf("SELECT seq_region.name, seq_region.length FROM seq_region WHERE seq_region.`name` REGEXP '^[[:digit:]]{1,2}$|^[xXyY]$|(?i)^mt$' AND seq_region.`coord_system_id` = %d", coordID)
stmtOut, err := db.Prepare(sqlQuery)
check(err)
defer stmtOut.Close()
stmtOut.Query()
rows, err := stmtOut.Query()
defer rows.Close()
check(err)
chromoFn := func(rows *sql.Rows, bulkRequest *elastic.BulkService) {
var name string
var length int
err = rows.Scan(&name, &length)
check(err)
chromo := Chromosome{ID: name, Length: length}
fmt.Printf("chromoID: %sn", chromo.ID)
req := elastic.NewBulkIndexRequest().
OpType("index").
Index("chromosomes").
Type("chromosome").
Id(chromo.ID).
Doc(chromo)
bulkRequest.Add(req)
}
elasticutil.IterateSQL(rows, client, chromoFn)
}
This service have other index which I can query the data with no problem, I only have problem when querying chromosomes
data.
Please let me know if I need to put more code so that I can give a bit more context on the problem, I just started on Go and Elasticsearch, and I tried reading the documentation, but it just leads to more confusion.
elasticsearch go
elasticsearch go
asked Nov 15 '18 at 17:49
user3794740user3794740
2516
2516
I got the service from here github.com/shusson/genesearch
– user3794740
Nov 15 '18 at 18:27
"I only have problem when querying chromosomes data". What problem? The code you show doesn't query ES at all. And in the very first paragraph you demonstrate that you can query the index successfully. It's really not clear what you're asking.
– Peter
Nov 15 '18 at 19:01
@Peter Sorry, if my question is not clear, as I'm still trying to understand ES and Go. So the piece of code that I attached there is for adding documents to thechromosomes
index that I have. I can query the index such that if I gohttp://129.94.14.234:9200/chromosomes/
I'll get the json file with the mappings of the chromosome, but what I want is the data on that index. If you're willing to see the repo of the service, it might give you better understanding of what I'm asking.
– user3794740
Nov 15 '18 at 19:15
129.94.14.234:9200/chromosomes/_search
– Peter
Nov 15 '18 at 21:00
@Peter I can see the data with/chromosomes/_search
, how do I get the data based on id? Also I'm still confused what's thetype
for?
– user3794740
Nov 15 '18 at 21:22
add a comment |
I got the service from here github.com/shusson/genesearch
– user3794740
Nov 15 '18 at 18:27
"I only have problem when querying chromosomes data". What problem? The code you show doesn't query ES at all. And in the very first paragraph you demonstrate that you can query the index successfully. It's really not clear what you're asking.
– Peter
Nov 15 '18 at 19:01
@Peter Sorry, if my question is not clear, as I'm still trying to understand ES and Go. So the piece of code that I attached there is for adding documents to thechromosomes
index that I have. I can query the index such that if I gohttp://129.94.14.234:9200/chromosomes/
I'll get the json file with the mappings of the chromosome, but what I want is the data on that index. If you're willing to see the repo of the service, it might give you better understanding of what I'm asking.
– user3794740
Nov 15 '18 at 19:15
129.94.14.234:9200/chromosomes/_search
– Peter
Nov 15 '18 at 21:00
@Peter I can see the data with/chromosomes/_search
, how do I get the data based on id? Also I'm still confused what's thetype
for?
– user3794740
Nov 15 '18 at 21:22
I got the service from here github.com/shusson/genesearch
– user3794740
Nov 15 '18 at 18:27
I got the service from here github.com/shusson/genesearch
– user3794740
Nov 15 '18 at 18:27
"I only have problem when querying chromosomes data". What problem? The code you show doesn't query ES at all. And in the very first paragraph you demonstrate that you can query the index successfully. It's really not clear what you're asking.
– Peter
Nov 15 '18 at 19:01
"I only have problem when querying chromosomes data". What problem? The code you show doesn't query ES at all. And in the very first paragraph you demonstrate that you can query the index successfully. It's really not clear what you're asking.
– Peter
Nov 15 '18 at 19:01
@Peter Sorry, if my question is not clear, as I'm still trying to understand ES and Go. So the piece of code that I attached there is for adding documents to the
chromosomes
index that I have. I can query the index such that if I go http://129.94.14.234:9200/chromosomes/
I'll get the json file with the mappings of the chromosome, but what I want is the data on that index. If you're willing to see the repo of the service, it might give you better understanding of what I'm asking.– user3794740
Nov 15 '18 at 19:15
@Peter Sorry, if my question is not clear, as I'm still trying to understand ES and Go. So the piece of code that I attached there is for adding documents to the
chromosomes
index that I have. I can query the index such that if I go http://129.94.14.234:9200/chromosomes/
I'll get the json file with the mappings of the chromosome, but what I want is the data on that index. If you're willing to see the repo of the service, it might give you better understanding of what I'm asking.– user3794740
Nov 15 '18 at 19:15
129.94.14.234:9200/chromosomes/_search
– Peter
Nov 15 '18 at 21:00
129.94.14.234:9200/chromosomes/_search
– Peter
Nov 15 '18 at 21:00
@Peter I can see the data with
/chromosomes/_search
, how do I get the data based on id? Also I'm still confused what's the type
for?– user3794740
Nov 15 '18 at 21:22
@Peter I can see the data with
/chromosomes/_search
, how do I get the data based on id? Also I'm still confused what's the type
for?– user3794740
Nov 15 '18 at 21:22
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53325234%2felastic-go-cannot-find-document%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53325234%2felastic-go-cannot-find-document%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I got the service from here github.com/shusson/genesearch
– user3794740
Nov 15 '18 at 18:27
"I only have problem when querying chromosomes data". What problem? The code you show doesn't query ES at all. And in the very first paragraph you demonstrate that you can query the index successfully. It's really not clear what you're asking.
– Peter
Nov 15 '18 at 19:01
@Peter Sorry, if my question is not clear, as I'm still trying to understand ES and Go. So the piece of code that I attached there is for adding documents to the
chromosomes
index that I have. I can query the index such that if I gohttp://129.94.14.234:9200/chromosomes/
I'll get the json file with the mappings of the chromosome, but what I want is the data on that index. If you're willing to see the repo of the service, it might give you better understanding of what I'm asking.– user3794740
Nov 15 '18 at 19:15
129.94.14.234:9200/chromosomes/_search
– Peter
Nov 15 '18 at 21:00
@Peter I can see the data with
/chromosomes/_search
, how do I get the data based on id? Also I'm still confused what's thetype
for?– user3794740
Nov 15 '18 at 21:22