Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 2.0

Best practices for storing IPs and view retrieval

4 replies [Last post]
  • Login or register to post comments
Sun, 02/03/2013 - 10:08
TimMeade
Offline
Joined: 01/27/2013
Groups: None

Looking for advice on storing system IPs.

Currently having some difficulty storing them and then retrieving counts of systems based on dates.

function (doc) {
if(doc.CACHEINSERTEPOCH && doc.PROXYIP) {
emit([doc.PROXYIP,doc.CACHEINSERTEPOCH],doc.PROXYIP,null);
}
}

reduce _count

Kind of works. Using startkey of '000.000.000.000' and endkey of '999.999.999.999' I got all the servers and the counts appear proper, except one server is missing. When I explicitly ask for that server i get those values.

Seems there should be a better safer way to get all IPs based on an epoch period counts.

Thanks in advance.

Tim

Top
  • Login or register to post comments
Sun, 02/03/2013 - 22:55
dipti
Offline
Joined: 11/02/2011
Groups:

Tim,

Your emit statement should only include the key and the value. You can use a compound key. So in your example, you should emit

emit([doc.PROXYIP,doc.CACHEINSERTEPOCH],null);

This will return the document IDs when you execute a range lookup. Also, depending on what you are looking for you may need to use the inclusive_end parameter.

Top
  • Login or register to post comments
Mon, 02/04/2013 - 02:30
tgrall
Offline
Joined: 09/05/2012
Groups: None

Hello

In addition to the comment made by Dipti I am inviting your to take a look to these blog posts that are quite helpful where working with queries (sorting, range, compound keys...)

- Sorting : http://blog.couchbase.com/understanding-letter-ordering-view-queries
- Compound Keys : http://blog.couchbase.com/understanding-grouplevel-view-queries-compound...

Regards

__________________

Tug
@tgrall

Top
  • Login or register to post comments
Mon, 02/04/2013 - 05:43
TimMeade
Offline
Joined: 01/27/2013
Groups: None

Thanks everyone. Very helpful.

I've changed the map to:

function (doc) {
if(doc.CACHEINSERTEPOCH && doc.PROXYIP) {
emit([doc.PROXYIP,doc.CACHEINSERTEPOCH],null);
}
}

and set group level to 1 to get the _count of the PROXYIP.

Works great; EXCEPT;

There is a server missing.

The 9 servers on the 4.31.xxx.xxx domain all show up with counts perfectly.

The 1 development server on 8.29.xxx.xxx does not show up at all. I have verified the documents for this server are there and accessible.

I tried it with now start/end key and with a start key of ["0",0] and end key of ["Z",9359981403] nothing seems to make a difference.

If I set the start/end keys to be explicitly the lost server, it does return fine. But then it's just the 1 server and the 9 are out of the key ranges.

Thanks again.

Top
  • Login or register to post comments
Sun, 02/17/2013 - 06:02
tgrall
Offline
Joined: 09/05/2012
Groups: None

Hello,

Can you share the exact keys that we do some tests?

Regards

__________________

Tug
@tgrall

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker